forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace.py
36 lines (30 loc) · 1.24 KB
/
replace.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
from vbench.api import Benchmark
from datetime import datetime
common_setup = """from pandas_vb_common import *
from datetime import timedelta
N = 1000000
try:
rng = date_range('1/1/2000', periods=N, freq='min')
except NameError:
rng = DatetimeIndex('1/1/2000', periods=N, offset=datetools.Minute())
date_range = DateRange
ts = Series(np.random.randn(N), index=rng)
"""
large_dict_setup = """from pandas_vb_common import *
from pandas.compat import range
n = 10 ** 6
start_value = 10 ** 5
to_rep = dict((i, start_value + i) for i in range(n))
s = Series(np.random.randint(n, size=10 ** 3))
"""
replace_fillna = Benchmark('ts.fillna(0., inplace=True)', common_setup,
name='replace_fillna',
start_date=datetime(2012, 4, 4))
replace_replacena = Benchmark('ts.replace(np.nan, 0., inplace=True)',
common_setup,
name='replace_replacena',
start_date=datetime(2012, 5, 15))
replace_large_dict = Benchmark('s.replace(to_rep, inplace=True)',
large_dict_setup,
name='replace_large_dict',
start_date=datetime(2014, 4, 6))