forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimedelta.py
60 lines (39 loc) · 1.49 KB
/
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
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
from .pandas_vb_common import *
from pandas import to_timedelta, Timestamp
class timedelta_convert_int(object):
goal_time = 0.2
def setup(self):
self.arr = np.random.randint(0, 1000, size=10000)
def time_timedelta_convert_int(self):
to_timedelta(self.arr, unit='s')
class timedelta_convert_string(object):
goal_time = 0.2
def setup(self):
self.arr = np.random.randint(0, 1000, size=10000)
self.arr = ['{0} days'.format(i) for i in self.arr]
def time_timedelta_convert_string(self):
to_timedelta(self.arr)
class timedelta_convert_string_seconds(object):
goal_time = 0.2
def setup(self):
self.arr = np.random.randint(0, 60, size=10000)
self.arr = ['00:00:{0:02d}'.format(i) for i in self.arr]
def time_timedelta_convert_string_seconds(self):
to_timedelta(self.arr)
class timedelta_convert_bad_parse(object):
goal_time = 0.2
def setup(self):
self.arr = np.random.randint(0, 1000, size=10000)
self.arr = ['{0} days'.format(i) for i in self.arr]
self.arr[-1] = 'apple'
def time_timedelta_convert_coerce(self):
to_timedelta(self.arr, errors='coerce')
def time_timedelta_convert_ignore(self):
to_timedelta(self.arr, errors='ignore')
class timedelta_add_overflow(object):
goal_time = 0.2
def setup(self):
self.td = to_timedelta(np.arange(1000000))
self.ts = Timestamp('2000')
def test_add_td_ts(self):
self.td + self.ts