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

[FEA] Include a SettingWithCopyWarning similar to pandas #2684

Closed
Tracked by #12793
beckernick opened this issue Aug 26, 2019 · 1 comment
Closed
Tracked by #12793

[FEA] Include a SettingWithCopyWarning similar to pandas #2684

beckernick opened this issue Aug 26, 2019 · 1 comment
Labels
feature request New feature or request Python Affects Python cuDF API.

Comments

@beckernick
Copy link
Member

beckernick commented Aug 26, 2019

Users sometimes attempt to set a value on dataframe slices that are actually copies of the original dataframe. This does not usually error, but instead often silently results in downstream results being incorrect. This is common enough in pandas that they've included a warning to inform users of when this is happening. We should explore implementing something similar.

import pandas as pd

df = pd.DataFrame({'a':range(5)})
df[df['a'] >= 3]['a'] = 100
df
...: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  after removing the cwd from sys.path.
   a
0  0
1  1
2  2
3  3
4  4

See this portion of the pandas codebase for more information.

@beckernick beckernick added feature request New feature or request Needs Triage Need team to review and classify labels Aug 26, 2019
@kkraus14 kkraus14 added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Sep 3, 2019
@vyasr
Copy link
Contributor

vyasr commented May 10, 2024

copy-on-write is available as of pandas 2.0 and will become the default in pandas 3.0. This feature is also available in cudf #12011. With copy-on-write, the need for the SettingWithCopyWarning goes away. Given that this is the (not too distant) future, there is no need to mirror this behavior in cudf since it has a clear timeline to be removed from pandas.

@vyasr vyasr closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Python Affects Python cuDF API.
Projects
None yet
Development

No branches or pull requests

3 participants