Series.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method='pad', axis=None)
[source]
Replace values given in ‘to_replace’ with ‘value’.
Parameters: |
to_replace : str, regex, list, dict, Series, numeric, or None
See the examples section for examples of each of these. value : scalar, dict, list, str, regex, default None Value to use to fill holes (e.g. 0), alternately a dict of values specifying which value to use for each column (columns not in the dict will not be filled). Regular expressions, strings and lists or dicts of such objects are also allowed. inplace : boolean, default False If True, in place. Note: this will modify any other views on this object (e.g. a column form a DataFrame). Returns the caller if this is True. limit : int, default None Maximum size gap to forward or backward fill regex : bool or same types as Whether to interpret method : string, optional, {‘pad’, ‘ffill’, ‘bfill’} The method to use when for replacement, when |
---|---|
Returns: |
filled : NDFrame |
Raises: |
AssertionError
TypeError
ValueError
|
See also
NDFrame.reindex
, NDFrame.asfreq
, NDFrame.fillna
re.sub
. The rules for substitution for re.sub
are the same.
© 2011–2012 Lambda Foundry, Inc. and PyData Development Team
© 2008–2011 AQR Capital Management, LLC
© 2008–2014 the pandas development team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.Series.replace.html