Skip to content

Series.replace and DataFrame.replace have same docstring? #13852

Closed
@kyleabeauchamp

Description

@kyleabeauchamp
In [4]: pd.__version__
Out[4]: u'0.18.1'

The docstring for Series.replace refers to looking up column names, which AFAIK doesn't make sense for the Series version of replace. It seems like the Series function is just blindly inheriting the DataFrame docstring?

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.replace.html?highlight=replace#pandas.Series.replace

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html?highlight=replace#pandas.DataFrame.replace

For example, the following trivial example of Series.replace() does not agree with the docstring:

import pandas as pd

x = pd.DataFrame([dict(A=1, B=2, C=3), dict(A=2, B=3, C=4), dict(A=3, B=4, C=5)])

print(x.A.replace({1:0}))
print(x.A)

0    0
1    2
2    3
Name: A, dtype: int64
0    1
1    2
2    3
Name: A, dtype: int64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions