pandas 0.9.1 documentation

pandas.Series.replace

Series.replace(to_replace, value=None, method='pad', inplace=False, limit=None)

Replace arbitrary values in a Series

Parameters :

to_replace : list or dict

list of values to be replaced or dict of replacement values

value : anything

if to_replace is a list then value is the replacement value

method : {‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default ‘pad’

Method to use for filling holes in reindexed Series pad / ffill: propagate last valid observation forward to next valid backfill / bfill: use NEXT valid observation to fill gap

inplace : boolean, default False

If True, fill the Series in place. Note: this will modify any other views on this Series, for example a column in a DataFrame. Returns a reference to the filled object, which is self if inplace=True

limit : int, default None

Maximum size gap to forward or backward fill

Returns :

replaced : Series

See also

fillna, reindex, asfreq

Notes

replace does not distinguish between NaN and None