|
7 | 7 | class DatetimeStrftime:
|
8 | 8 | timeout = 1500
|
9 | 9 | params = [1000, 10000]
|
10 |
| - param_names = ["obs"] |
| 10 | + param_names = ["nobs"] |
11 | 11 |
|
12 |
| - def setup(self, obs): |
| 12 | + def setup(self, nobs): |
13 | 13 | d = "2018-11-29"
|
14 | 14 | dt = "2018-11-26 11:18:27.0"
|
15 | 15 | self.data = pd.DataFrame(
|
16 | 16 | {
|
17 |
| - "dt": [np.datetime64(dt)] * obs, |
18 |
| - "d": [np.datetime64(d)] * obs, |
19 |
| - "r": [np.random.uniform()] * obs, |
| 17 | + "dt": [np.datetime64(dt)] * nobs, |
| 18 | + "d": [np.datetime64(d)] * nobs, |
| 19 | + "r": [np.random.uniform()] * nobs, |
20 | 20 | }
|
21 | 21 | )
|
22 | 22 |
|
23 |
| - def time_frame_date_to_str(self, obs): |
| 23 | + def time_frame_date_to_str(self, nobs): |
24 | 24 | self.data["d"].astype(str)
|
25 | 25 |
|
26 |
| - def time_frame_date_formatting_default(self, obs): |
| 26 | + def time_frame_date_formatting_default(self, nobs): |
| 27 | + self.data["d"].dt.strftime(date_format=None) |
| 28 | + |
| 29 | + def time_frame_date_formatting_default_explicit(self, nobs): |
27 | 30 | self.data["d"].dt.strftime(date_format="%Y-%m-%d")
|
28 | 31 |
|
29 |
| - def time_frame_date_formatting_custom(self, obs): |
| 32 | + def time_frame_date_formatting_custom(self, nobs): |
30 | 33 | self.data["d"].dt.strftime(date_format="%Y---%m---%d")
|
31 | 34 |
|
32 |
| - def time_frame_datetime_to_str(self, obs): |
| 35 | + def time_frame_datetime_to_str(self, nobs): |
33 | 36 | self.data["dt"].astype(str)
|
34 | 37 |
|
35 |
| - def time_frame_datetime_formatting_default_date_only(self, obs): |
| 38 | + def time_frame_datetime_formatting_default(self, nobs): |
| 39 | + self.data["dt"].dt.strftime(date_format=None) |
| 40 | + |
| 41 | + def time_frame_datetime_formatting_default_explicit_date_only(self, nobs): |
36 | 42 | self.data["dt"].dt.strftime(date_format="%Y-%m-%d")
|
37 | 43 |
|
38 |
| - def time_frame_datetime_formatting_default(self, obs): |
| 44 | + def time_frame_datetime_formatting_default_explicit(self, nobs): |
39 | 45 | self.data["dt"].dt.strftime(date_format="%Y-%m-%d %H:%M:%S")
|
40 | 46 |
|
41 |
| - def time_frame_datetime_formatting_default_with_float(self, obs): |
| 47 | + def time_frame_datetime_formatting_default_with_float(self, nobs): |
42 | 48 | self.data["dt"].dt.strftime(date_format="%Y-%m-%d %H:%M:%S.%f")
|
43 | 49 |
|
44 |
| - def time_frame_datetime_formatting_custom(self, obs): |
| 50 | + def time_frame_datetime_formatting_custom(self, nobs): |
45 | 51 | self.data["dt"].dt.strftime(date_format="%Y-%m-%d --- %H:%M:%S")
|
46 | 52 |
|
47 | 53 |
|
| 54 | +class PeriodStrftime: |
| 55 | + timeout = 1500 |
| 56 | + params = ([1000, 10000], ["D", "H"]) |
| 57 | + param_names = ["nobs", "freq"] |
| 58 | + |
| 59 | + def setup(self, nobs, freq): |
| 60 | + self.data = pd.DataFrame( |
| 61 | + { |
| 62 | + "p": pd.period_range(start="2000-01-01", periods=nobs, freq=freq), |
| 63 | + "r": [np.random.uniform()] * nobs, |
| 64 | + } |
| 65 | + ) |
| 66 | + self.data["i"] = self.data["p"] |
| 67 | + self.data.set_index("i", inplace=True) |
| 68 | + if freq == "D": |
| 69 | + self.default_fmt = "%Y-%m-%d" |
| 70 | + elif freq == "H": |
| 71 | + self.default_fmt = "%Y-%m-%d %H:00" |
| 72 | + |
| 73 | + def time_frame_period_to_str(self, nobs, freq): |
| 74 | + self.data["p"].astype(str) |
| 75 | + |
| 76 | + def time_frame_period_formatting_default(self, nobs, freq): |
| 77 | + self.data["p"].dt.strftime(date_format=None) |
| 78 | + |
| 79 | + def time_frame_period_formatting_default_explicit(self, nobs, freq): |
| 80 | + self.data["p"].dt.strftime(date_format=self.default_fmt) |
| 81 | + |
| 82 | + def time_frame_period_formatting_index_default(self, nobs, freq): |
| 83 | + self.data.index.format() |
| 84 | + |
| 85 | + def time_frame_period_formatting_index_default_explicit(self, nobs, freq): |
| 86 | + self.data.index.format(self.default_fmt) |
| 87 | + |
| 88 | + def time_frame_period_formatting_custom(self, nobs, freq): |
| 89 | + self.data["p"].dt.strftime(date_format="%Y-%m-%d --- %H:%M:%S") |
| 90 | + |
| 91 | + def time_frame_period_formatting_iso8601_strftime_Z(self, nobs, freq): |
| 92 | + self.data["p"].dt.strftime(date_format="%Y-%m-%dT%H:%M:%SZ") |
| 93 | + |
| 94 | + def time_frame_period_formatting_iso8601_strftime_offset(self, nobs, freq): |
| 95 | + """Not optimized yet as %z is not supported by `convert_strftime_format`""" |
| 96 | + self.data["p"].dt.strftime(date_format="%Y-%m-%dT%H:%M:%S%z") |
| 97 | + |
| 98 | + |
48 | 99 | class BusinessHourStrftime:
|
49 | 100 | timeout = 1500
|
50 | 101 | params = [1000, 10000]
|
51 |
| - param_names = ["obs"] |
| 102 | + param_names = ["nobs"] |
52 | 103 |
|
53 |
| - def setup(self, obs): |
| 104 | + def setup(self, nobs): |
54 | 105 | self.data = pd.DataFrame(
|
55 | 106 | {
|
56 |
| - "off": [offsets.BusinessHour()] * obs, |
| 107 | + "off": [offsets.BusinessHour()] * nobs, |
57 | 108 | }
|
58 | 109 | )
|
59 | 110 |
|
60 |
| - def time_frame_offset_str(self, obs): |
| 111 | + def time_frame_offset_str(self, nobs): |
61 | 112 | self.data["off"].apply(str)
|
62 | 113 |
|
63 |
| - def time_frame_offset_repr(self, obs): |
| 114 | + def time_frame_offset_repr(self, nobs): |
64 | 115 | self.data["off"].apply(repr)
|
0 commit comments