Skip to content

BUG: replace with inplace=True does not respect CoW #51277

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
3 tasks done
phofl opened this issue Feb 9, 2023 · 4 comments · Fixed by #51278
Closed
3 tasks done

BUG: replace with inplace=True does not respect CoW #51277

phofl opened this issue Feb 9, 2023 · 4 comments · Fixed by #51278
Milestone

Comments

@phofl
Copy link
Member

phofl commented Feb 9, 2023

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

df = DataFrame({"a": [1.5, 2, 3]})
arr_a = get_array(df, "a")
view = df[:]
df.replace(to_replace=[1.5], value=15.5, inplace=True)
print(arr_a)

Same with to_replace=1.5

Issue Description

arr_a should not get changed

the scalar case is addressed by #50918

Expected Behavior

see above

Installed Versions

Replace this line with the output of pd.show_versions()

@phofl phofl added Bug Needs Triage Issue that has not been reviewed by a pandas team member replace replace method Copy / view semantics and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 9, 2023
@phofl
Copy link
Member Author

phofl commented Feb 9, 2023

Should fix for 2.0

@phofl phofl added this to the 2.0 milestone Feb 9, 2023
@lithomas1
Copy link
Member

@phofl We should be checking everything else in group 2 of the PDEP as well right (adding tests if it works)?
(Still would need to check where, fillna(needs tests at the very least), mask, clip)

@phofl
Copy link
Member Author

phofl commented Feb 9, 2023

did not test clip (always forgetting about it), the others all respect cow, also have a pr for fillna

@lithomas1
Copy link
Member

Opened a PR for the rest.

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

Successfully merging a pull request may close this issue.

2 participants