forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio_bench.py
59 lines (47 loc) · 1.92 KB
/
io_bench.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
from vbench.api import Benchmark
from datetime import datetime
common_setup = """from pandas_vb_common import *
"""
#----------------------------------------------------------------------
# read_csv
setup1 = common_setup + """
index = [rands(10) for _ in xrange(10000)]
df = DataFrame({'float1' : randn(10000),
'float2' : randn(10000),
'string1' : ['foo'] * 10000,
'bool1' : [True] * 10000,
'int1' : np.random.randint(0, 100000, size=10000)},
index=index)
df.to_csv('__test__.csv')
"""
read_csv_standard = Benchmark("read_csv('__test__.csv')", setup1,
start_date=datetime(2011, 9, 15))
#----------------------------------------------------------------------
# write_csv
setup2 = common_setup + """
index = [rands(10) for _ in xrange(10000)]
df = DataFrame({'float1' : randn(10000),
'float2' : randn(10000),
'string1' : ['foo'] * 10000,
'bool1' : [True] * 10000,
'int1' : np.random.randint(0, 100000, size=10000)},
index=index)
"""
write_csv_standard = Benchmark("df.to_csv('__test__.csv')", setup2,
start_date=datetime(2011, 9, 15))
#----------------------------------
setup = common_setup + """
df = DataFrame(np.random.randn(3000, 30))
"""
frame_to_csv = Benchmark("df.to_csv('__test__.csv')", setup,
start_date=datetime(2011, 1, 1))
#----------------------------------------------------------------------
# parse dates, ISO8601 format
setup = common_setup + """
rng = date_range('1/1/2000', periods=1000)
data = '\\n'.join(rng.map(lambda x: x.strftime("%Y-%m-%d %H:%M:%S")))
"""
stmt = ("read_csv(StringIO(data), header=None, names=['foo'], "
" parse_dates=['foo'])")
read_parse_dates_iso8601 = Benchmark(stmt, setup,
start_date=datetime(2012, 3, 1))