forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackers.py
94 lines (64 loc) · 2.21 KB
/
packers.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
from vbench.api import Benchmark
from datetime import datetime
start_date = datetime(2013, 5, 1)
common_setup = """from pandas_vb_common import *
import os
import pandas as pd
from pandas.core import common as com
f = '__test__.msg'
def remove(f):
try:
os.remove(f)
except:
pass
index = date_range('20000101',periods=50000,freq='H')
df = DataFrame({'float1' : randn(50000),
'float2' : randn(50000)},
index=index)
remove(f)
"""
#----------------------------------------------------------------------
# msgpack
setup = common_setup + """
df.to_msgpack(f)
"""
packers_read_pack = Benchmark("pd.read_msgpack(f)", setup, start_date=start_date)
setup = common_setup + """
"""
packers_write_pack = Benchmark("df.to_msgpack(f)", setup, cleanup="remove(f)", start_date=start_date)
#----------------------------------------------------------------------
# pickle
setup = common_setup + """
df.to_pickle(f)
"""
packers_read_pickle = Benchmark("pd.read_pickle(f)", setup, start_date=start_date)
setup = common_setup + """
"""
packers_write_pickle = Benchmark("df.to_pickle(f)", setup, cleanup="remove(f)", start_date=start_date)
#----------------------------------------------------------------------
# csv
setup = common_setup + """
df.to_csv(f)
"""
packers_read_csv = Benchmark("pd.read_csv(f)", setup, start_date=start_date)
setup = common_setup + """
"""
packers_write_csv = Benchmark("df.to_csv(f)", setup, cleanup="remove(f)", start_date=start_date)
#----------------------------------------------------------------------
# hdf store
setup = common_setup + """
df.to_hdf(f,'df')
"""
packers_read_hdf_store = Benchmark("pd.read_hdf(f,'df')", setup, start_date=start_date)
setup = common_setup + """
"""
packers_write_hdf_store = Benchmark("df.to_hdf(f,'df')", setup, cleanup="remove(f)", start_date=start_date)
#----------------------------------------------------------------------
# hdf table
setup = common_setup + """
df.to_hdf(f,'df',table=True)
"""
packers_read_hdf_table = Benchmark("pd.read_hdf(f,'df')", setup, start_date=start_date)
setup = common_setup + """
"""
packers_write_hdf_table = Benchmark("df.to_hdf(f,'df',table=True)", setup, cleanup="remove(f)", start_date=start_date)