forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe_methods.py
35 lines (26 loc) · 1.06 KB
/
frame_methods.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
from vbench.benchmark import Benchmark
from datetime import datetime
common_setup = """from pandas_vb_common import *
"""
#----------------------------------------------------------------------
# lookup
setup = common_setup + """
df = DataFrame(np.random.randn(10000, 8), columns=list('abcdefgh'))
df['foo'] = 'bar'
row_labels = list(df.index[::10])[:900]
col_labels = list(df.columns) * 100
row_labels_all = list(df.index) * len(df.columns)
col_labels_all = list(df.columns) * len(df.index)
"""
frame_fancy_lookup = Benchmark('df.lookup(row_labels, col_labels)', setup,
start_date=datetime(2012, 1, 12))
frame_fancy_lookup_all = Benchmark('df.lookup(row_labels_all, col_labels_all)',
setup,
start_date=datetime(2012, 1, 12))
#----------------------------------------------------------------------
# fillna in place
setup = common_setup + """
df = DataFrame(randn(10000, 100))
df.values[::2] = np.nan
"""
frame_fillna_inplace = Benchmark('df.fillna(0, inplace=True)', setup)