forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimedelta.py
32 lines (24 loc) · 898 Bytes
/
timedelta.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
from vbench.api import Benchmark
from datetime import datetime
common_setup = """from pandas_vb_common import *
from pandas import to_timedelta
"""
#----------------------------------------------------------------------
# conversion
setup = common_setup + """
arr = np.random.randint(0,1000,size=10000)
"""
stmt = "to_timedelta(arr,unit='s')"
timedelta_convert_int = Benchmark(stmt, setup, start_date=datetime(2014, 1, 1))
setup = common_setup + """
arr = np.random.randint(0,1000,size=10000)
arr = [ '{0} days'.format(i) for i in arr ]
"""
stmt = "to_timedelta(arr)"
timedelta_convert_string = Benchmark(stmt, setup, start_date=datetime(2014, 1, 1))
setup = common_setup + """
arr = np.random.randint(0,60,size=10000)
arr = [ '00:00:{0:02d}'.format(i) for i in arr ]
"""
stmt = "to_timedelta(arr)"
timedelta_convert_string_seconds = Benchmark(stmt, setup, start_date=datetime(2014, 1, 1))