forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimestamp.py
116 lines (77 loc) · 2.72 KB
/
timestamp.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import datetime
from pandas import Timestamp
import pytz
class TimestampConstruction(object):
def time_parse_iso8601_no_tz(self):
Timestamp('2017-08-25 08:16:14')
def time_parse_iso8601_tz(self):
Timestamp('2017-08-25 08:16:14-0500')
def time_parse_dateutil(self):
Timestamp('2017/08/25 08:16:14 AM')
def time_parse_today(self):
Timestamp('today')
def time_parse_now(self):
Timestamp('now')
def time_fromordinal(self):
Timestamp.fromordinal(730120)
def time_fromtimestamp(self):
Timestamp.fromtimestamp(1515448538)
class TimestampProperties(object):
_tzs = [None, pytz.timezone('Europe/Amsterdam')]
_freqs = [None, 'B']
params = [_tzs, _freqs]
param_names = ['tz', 'freq']
def setup(self, tz, freq):
self.ts = Timestamp('2017-08-25 08:16:14', tzinfo=tz, freq=freq)
def time_tz(self, tz, freq):
self.ts.tz
def time_dayofweek(self, tz, freq):
self.ts.dayofweek
def time_weekday_name(self, tz, freq):
self.ts.weekday_name
def time_dayofyear(self, tz, freq):
self.ts.dayofyear
def time_week(self, tz, freq):
self.ts.week
def time_quarter(self, tz, freq):
self.ts.quarter
def time_days_in_month(self, tz, freq):
self.ts.days_in_month
def time_freqstr(self, tz, freq):
self.ts.freqstr
def time_is_month_start(self, tz, freq):
self.ts.is_month_start
def time_is_month_end(self, tz, freq):
self.ts.is_month_end
def time_is_quarter_start(self, tz, freq):
self.ts.is_quarter_start
def time_is_quarter_end(self, tz, freq):
self.ts.is_quarter_end
def time_is_year_start(self, tz, freq):
self.ts.is_quarter_end
def time_is_year_end(self, tz, freq):
self.ts.is_quarter_end
def time_is_leap_year(self, tz, freq):
self.ts.is_quarter_end
def time_microsecond(self, tz, freq):
self.ts.microsecond
class TimestampOps(object):
params = [None, 'US/Eastern']
param_names = ['tz']
def setup(self, tz):
self.ts = Timestamp('2017-08-25 08:16:14', tz=tz)
def time_replace_tz(self, tz):
self.ts.replace(tzinfo=pytz.timezone('US/Eastern'))
def time_replace_None(self, tz):
self.ts.replace(tzinfo=None)
def time_to_pydatetime(self, tz):
self.ts.to_pydatetime()
def time_normalize(self, tz):
self.ts.normalize()
class TimestampAcrossDst(object):
def setup(self):
dt = datetime.datetime(2016, 3, 27, 1)
self.tzinfo = pytz.timezone('CET').localize(dt, is_dst=False).tzinfo
self.ts2 = Timestamp(dt)
def time_replace_across_dst(self):
self.ts2.replace(tzinfo=self.tzinfo)