Skip to content

Commit 3ea3f91

Browse files
committed
TST: add benchmarks for timestamp shortcut
1 parent d2adb4f commit 3ea3f91

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

asv_bench/benchmarks/tslibs/timestamp.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import dateutil
44
import pytz
55

6-
from pandas import Timestamp
6+
from pandas import Series, Timestamp
77

88

99
class TimestampConstruction:
10+
def setup(self):
11+
self.ts = Timestamp("2020-01-01 00:00:00")
12+
self.ts_series = Series(range(10000)).astype('<M8[ns]')
13+
1014
def time_parse_iso8601_no_tz(self):
1115
Timestamp("2017-08-25 08:16:14")
1216

@@ -28,6 +32,12 @@ def time_fromordinal(self):
2832
def time_fromtimestamp(self):
2933
Timestamp.fromtimestamp(1515448538)
3034

35+
def time_identity_scalar(self):
36+
Timestamp(self.ts)
37+
38+
def time_identity_series_apply(self):
39+
self.ts_series.apply(lambda x: Timestamp(x))
40+
3141

3242
class TimestampProperties:
3343
_tzs = [None, pytz.timezone("Europe/Amsterdam"), pytz.UTC, dateutil.tz.tzutc()]

0 commit comments

Comments
 (0)