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

SettingWithCopyWarning in a plotting cell #314

Closed
zoghbi-a opened this issue Aug 21, 2024 · 0 comments · Fixed by #315
Closed

SettingWithCopyWarning in a plotting cell #314

zoghbi-a opened this issue Aug 21, 2024 · 0 comments · Fixed by #315
Labels
bug Something isn't working use case: forced photometry

Comments

@zoghbi-a
Copy link
Contributor

The following two lines throw a SettingWithCopyWarning warning (I am using pandas 2.2.2) because merged_24 is a view of the original merged DataFrame and not a copy.

/tmp/ipykernel_209/3386606497.py:13: 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
  merged_24['F5.8divF3.6'] = merged_24.ch3flux / merged_24.ch1flux

I think this merged_24 should be a copy:

merged_24 = merged[(merged.flux_24 >= 0) ].copy()
@bsipocz bsipocz added bug Something isn't working use case: forced photometry labels Aug 21, 2024
zoghbi-a added a commit that referenced this issue Aug 22, 2024
This fixes the `SettingWithCopyWarning` warning. See #314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working use case: forced photometry
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants