Vbench performance benchmarks for pandas

replace

replace_putmask

Benchmark setup

from pandas_vb_common import *
from datetime import timedelta
import pandas._tseries as lib
N = 1000000

try:
    rng = date_range('1/1/2000', periods=N, freq='min')
except NameError:
    rng = DateRange('1/1/2000', periods=N, offset=datetools.Minute())
    date_range = DateRange

ts = Series(np.random.randn(N), index=rng)

def replace_slow(ser, old, new):
    lib.slow_replace(ser.values, old, new)
    return ser

Benchmark statement

replace_slow(ts, np.nan, 0.)

Performance graph

_images/replace_putmask.png

replace_fillna

Benchmark setup

from pandas_vb_common import *
from datetime import timedelta
import pandas._tseries as lib
N = 1000000

try:
    rng = date_range('1/1/2000', periods=N, freq='min')
except NameError:
    rng = DateRange('1/1/2000', periods=N, offset=datetools.Minute())
    date_range = DateRange

ts = Series(np.random.randn(N), index=rng)

def replace_slow(ser, old, new):
    lib.slow_replace(ser.values, old, new)
    return ser

Benchmark statement

ts.fillna(0., inplace=True)

Performance graph

_images/replace_fillna.png

replace_replacena

Benchmark setup

from pandas_vb_common import *
from datetime import timedelta
import pandas._tseries as lib
N = 1000000

try:
    rng = date_range('1/1/2000', periods=N, freq='min')
except NameError:
    rng = DateRange('1/1/2000', periods=N, offset=datetools.Minute())
    date_range = DateRange

ts = Series(np.random.randn(N), index=rng)

def replace_slow(ser, old, new):
    lib.slow_replace(ser.values, old, new)
    return ser

Benchmark statement

ts.replace(np.nan, 0., inplace=True)

Performance graph

_images/replace_replacena.png