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

suppress the FutureWarning: Downcasting behavior in replace is depr… #560

Closed
wants to merge 7 commits into from

Conversation

matentzn
Copy link
Collaborator

@matentzn matentzn commented Nov 6, 2024

…ecated

Previously we got

/Users/matentzn/ws/sssom-py/src/sssom/util.py:168: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  df = df.replace("", np.nan)

Here I am hiding the root cause of the issue (which would require me to ensure the I am not type casting accidentally while replacing) by surpressing the warning.

…ecated

Previously we got

```
/Users/matentzn/ws/sssom-py/src/sssom/util.py:168: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  df = df.replace("", np.nan)
```

Here I am hiding the root cause of the issue (which would require me to ensure the I am not type casting accidentally while replacing) by surpressing the warning.
ChainedAssignmentError: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
When using the Copy-on-Write mode, such inplace method never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy.
@matentzn
Copy link
Collaborator Author

matentzn commented Nov 8, 2024

Closing in favour of #561

@matentzn matentzn closed this Nov 8, 2024
@matentzn matentzn deleted the supress-type-warning-pandas branch November 8, 2024 21:45
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

Successfully merging this pull request may close these issues.

1 participant