Skip to content

API: pandas.Series.replace has different method signature to pandas.DataFrame.replace #4555

Closed
@roblevy

Description

@roblevy

Using Pandas 0.12.0

It's hard to think of why a DataFrame would allow a regex=True replace method, and a Series wouldn't. This must just be an oversight, right?

>>> test = pd.DataFrame(['hello','goodbye','thankyou'],columns=['to_replace'])
>>> test
  to_replace
0      hello
1    goodbye
2   thankyou
>>> test.replace("he", "je")
  to_replace
0      hello
1    goodbye
2   thankyou
>>> test.replace("he", "je", regex=True)
  to_replace
0      jello
1    goodbye
2   thankyou
>>> test['to_replace'].replace("he", "je", regex=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: replace() got an unexpected keyword argument 'regex'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions