Skip to content

BUG: Series.replace with to_replace dict and value=None, nonsensical error message #46689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from

Conversation

Kyrpel
Copy link

@Kyrpel Kyrpel commented Apr 7, 2022

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can either change the default for value (but I think lib.no_default was added on purpose) or clarify the error message

def test_replace_dictlike_value_None(self):
# GH46004
ser = pd.Series([1, 2, 3, 4])
result = ser.replace(to_replace={3: 33}, value=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is supposed to work. We are using lib.no_default as a sentinel to check if value was provided.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like when we have explicitly to_replace=dict_like and value=None it interpreted as a special case where None is different from lib.no_default. Maybe we need another conditional statement somewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should raise if value=None, otherwise lib.no_default does not make sense

@Kyrpel Kyrpel requested a review from phofl April 9, 2022 07:54
@jreback jreback changed the title Series BUG: Series.replace with to_replace dict and value=None, nonsensical error message Apr 10, 2022
@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Series Series data structure replace replace method Bug and removed Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Apr 29, 2022
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label May 30, 2022
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jun 21, 2022
@denizn
Copy link

denizn commented Jul 11, 2022

Hi there, just curious if this issue still persist. I seem to be getting the same error with series.replace. Could anyone enlighten me if there is a version that would have resolved this?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug replace replace method Series Series data structure Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.replace with to_replace dict and value=None, nonsensical error message
5 participants