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

pandas SettingWithCopyWarning #13

Open
C-H-Simpson opened this issue Apr 17, 2020 · 2 comments
Open

pandas SettingWithCopyWarning #13

C-H-Simpson opened this issue Apr 17, 2020 · 2 comments
Assignees

Comments

@C-H-Simpson
Copy link

I get a warning

_catalogue.py:305: 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

As far as I can tell, the output is as expected and this does not cause a problem.

@0xKoios
Copy link

0xKoios commented Apr 18, 2020

The warning offers a suggestion to rewrite as follows:
df.loc[df['A'] > 2, 'B'] = new_val

@scotthosking scotthosking self-assigned this May 12, 2020
@scotthosking
Copy link
Owner

scotthosking commented Jul 5, 2020

I've fixed this warning but now get the following:

In [2]: bp.catalogue(Var=['tas','uas'], Experiment='historical', complete_var_set=True)

/Users/scott/miniconda3/lib/python3.6/site-packages/pandas/core/indexing.py:845: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
self.obj[key] = _infer_fill_value(value)
/Users/scott/miniconda3/lib/python3.6/site-packages/pandas/core/indexing.py:966: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
self.obj[item] = s

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

No branches or pull requests

3 participants