Skip to content

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

@roblevy

Description

@roblevy
Contributor

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'

Activity

cpcloud

cpcloud commented on Aug 13, 2013

@cpcloud
Member

I think this will be fixed in 0.13 by the Series -> NDFrame refactor.

jreback

jreback commented on Aug 13, 2013

@jreback
Contributor

yep...#3482

jreback

jreback commented on Aug 13, 2013

@jreback
Contributor

@roblevy this is why the refactor is happening in the first place! (to provide this kind of consistency)

roblevy

roblevy commented on Aug 15, 2013

@roblevy
ContributorAuthor

Wow. I've just been pulled briefly into the whirlwind of development at the heart of the pandas project. So much going on that I (as a mere mortal user of the library) had no idea of. Look forward to 0.13.0. Keep up the amazing work!

jreback

jreback commented on Aug 16, 2013

@jreback
Contributor

related to #4118 / closed by #3482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cpcloud@jreback@roblevy

        Issue actions

          API: pandas.Series.replace has different method signature to pandas.DataFrame.replace · Issue #4555 · pandas-dev/pandas