forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrftime.py
64 lines (47 loc) · 1.78 KB
/
strftime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import pandas as pd
from pandas import offsets
class DatetimeStrftime:
timeout = 1500
params = [1000, 10000]
param_names = ["obs"]
def setup(self, obs):
d = "2018-11-29"
dt = "2018-11-26 11:18:27.0"
self.data = pd.DataFrame(
{
"dt": [np.datetime64(dt)] * obs,
"d": [np.datetime64(d)] * obs,
"r": [np.random.uniform()] * obs,
}
)
def time_frame_date_to_str(self, obs):
self.data["d"].astype(str)
def time_frame_date_formatting_default(self, obs):
self.data["d"].dt.strftime(date_format="%Y-%m-%d")
def time_frame_date_formatting_custom(self, obs):
self.data["d"].dt.strftime(date_format="%Y---%m---%d")
def time_frame_datetime_to_str(self, obs):
self.data["dt"].astype(str)
def time_frame_datetime_formatting_default_date_only(self, obs):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d")
def time_frame_datetime_formatting_default(self, obs):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d %H:%M:%S")
def time_frame_datetime_formatting_default_with_float(self, obs):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d %H:%M:%S.%f")
def time_frame_datetime_formatting_custom(self, obs):
self.data["dt"].dt.strftime(date_format="%Y-%m-%d --- %H:%M:%S")
class BusinessHourStrftime:
timeout = 1500
params = [1000, 10000]
param_names = ["obs"]
def setup(self, obs):
self.data = pd.DataFrame(
{
"off": [offsets.BusinessHour()] * obs,
}
)
def time_frame_offset_str(self, obs):
self.data["off"].apply(str)
def time_frame_offset_repr(self, obs):
self.data["off"].apply(repr)