Skip to content
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

CoW: Add warning for chained assignment with fillna #53779

Merged
merged 11 commits into from
Jul 6, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 21, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@phofl phofl requested a review from jorisvandenbossche June 21, 2023 20:40
@phofl
Copy link
Member Author

phofl commented Jun 21, 2023

@jorisvandenbossche I'd appreciate if you can take a look locally, I can't reproduce these failures on Mac

@mroeschke mroeschke added Copy / view semantics Warnings Warnings that appear or should be added to pandas labels Jun 22, 2023
@jbrockmendel
Copy link
Member

i get similar-looking failures on mac

@phofl
Copy link
Member Author

phofl commented Jul 2, 2023

Arm or intel? Purged environment and still can't reproduce...

@jbrockmendel
Copy link
Member

intel

@phofl
Copy link
Member Author

phofl commented Jul 2, 2023

Hm shit. Thx for checking

phofl and others added 3 commits July 3, 2023 00:03
@phofl
Copy link
Member Author

phofl commented Jul 3, 2023

This is Python version specific unfortunately... 3.10 has a different ref count compared to 3.11

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good!

df = DataFrame({"a": [1, np.nan, 2], "b": 1})
df_orig = df.copy()
if using_copy_on_write:
with tm.assert_produces_warning(ChainedAssignmentError):
Copy link
Member

Choose a reason for hiding this comment

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

There is a helper for this, with tm.raises_chained_assignment_error():, which will take care of the fact that it doesn't raise a warning on PyPy

Copy link
Member Author

Choose a reason for hiding this comment

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

thx

@phofl phofl merged commit 1f74636 into pandas-dev:main Jul 6, 2023
@phofl phofl deleted the cow_fillna_chained branch July 6, 2023 16:12
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Copy / view semantics Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants