forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel_ctor.py
74 lines (65 loc) · 2.42 KB
/
panel_ctor.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
from vbench.benchmark import Benchmark
from datetime import datetime
common_setup = """from pandas_vb_common import *
"""
#----------------------------------------------------------------------
# Panel.from_dict homogenization time
START_DATE = datetime(2011, 6, 1)
setup_same_index = common_setup + """
# create 100 dataframes with the same index
dr = np.asarray(DateRange(datetime(1990,1,1), datetime(2012,1,1)))
data_frames = {}
for x in xrange(100):
df = DataFrame({"a": [0]*len(dr), "b": [1]*len(dr),
"c": [2]*len(dr)}, index=dr)
data_frames[x] = df
"""
panel_from_dict_same_index = \
Benchmark("Panel.from_dict(data_frames)",
setup_same_index, name='panel_from_dict_same_index',
start_date=START_DATE, repeat=1, logy=True)
setup_equiv_indexes = common_setup + """
data_frames = {}
for x in xrange(100):
dr = np.asarray(DateRange(datetime(1990,1,1), datetime(2012,1,1)))
df = DataFrame({"a": [0]*len(dr), "b": [1]*len(dr),
"c": [2]*len(dr)}, index=dr)
data_frames[x] = df
"""
panel_from_dict_equiv_indexes = \
Benchmark("Panel.from_dict(data_frames)",
setup_equiv_indexes, name='panel_from_dict_equiv_indexes',
start_date=START_DATE, repeat=1, logy=True)
setup_all_different_indexes = common_setup + """
data_frames = {}
start = datetime(1990,1,1)
end = datetime(2012,1,1)
for x in xrange(100):
end += timedelta(days=1)
dr = np.asarray(DateRange(start, end))
df = DataFrame({"a": [0]*len(dr), "b": [1]*len(dr),
"c": [2]*len(dr)}, index=dr)
data_frames[x] = df
"""
panel_from_dict_all_different_indexes = \
Benchmark("Panel.from_dict(data_frames)",
setup_all_different_indexes,
name='panel_from_dict_all_different_indexes',
start_date=START_DATE, repeat=1, logy=True)
setup_two_different_indexes = common_setup + """
data_frames = {}
start = datetime(1990,1,1)
end = datetime(2012,1,1)
for x in xrange(100):
if x == 50:
end += timedelta(days=1)
dr = np.asarray(DateRange(start, end))
df = DataFrame({"a": [0]*len(dr), "b": [1]*len(dr),
"c": [2]*len(dr)}, index=dr)
data_frames[x] = df
"""
panel_from_dict_two_different_indexes = \
Benchmark("Panel.from_dict(data_frames)",
setup_two_different_indexes,
name='panel_from_dict_two_different_indexes',
start_date=START_DATE, repeat=1, logy=True)