Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle two warnings that pollute the output of sssom-py CLI (#561)
In this commit we 1. introduce pd.set_option("future.no_silent_downcasting", True) to heed the warning pandas started recently producing: 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.replace("", np.nan, inplace=True) 2. Fix a case where we were using inplace=True when updating a pandas data frame in the wrong way, leading to the following warning. We used the opportunity to simplify that piece of code as well, thanks @gouttegd 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. 3. lastly, we simplified some code where we introduced pandas.DataFrame.infer_objects(), which previously had a complicated conditional depending on the specific pandas version on whether the copy=False parameter is needed. It is not needed, because we also set pandas.mode.copy_on_write to true in #4cad7d6d8b905728f14a90d3d4c6d591b520cd3b.
- Loading branch information