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

set_dataframe results in SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. #542

Open
BadrulAlomIOG opened this issue Jun 21, 2022 · 0 comments

Comments

@BadrulAlomIOG
Copy link

When using the set_dataframe to copy in a Pandas dataframe into Googlesheets one gets the standard Python error:

worksheet.py:1366: 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
  df[col] = df[col].astype('unicode').replace('<NA>', nan)

It doesn't impact the end result - the values still get copied but it's not following Python best practice.

To reproduce I believe you can provide any Pandas dataframe to the set_dataframe function.

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

No branches or pull requests

2 participants