nasa-fornax / fornax-demo-notebooks

Demo notebooks for the Fornax project
https://nasa-fornax.github.io/fornax-demo-notebooks/
BSD 3-Clause "New" or "Revised" License
9 stars 19 forks source link

SettingWithCopyWarning in a plotting cell #314

Closed zoghbi-a closed 3 months ago

zoghbi-a commented 3 months ago

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()