Skip to content

Fix FutureWarning from pandas 2.3.1 (ChainedAssignmentError: behaviour will change in pandas 3.0!) #577

Description

@t-b

Python: 3.14.0rc2+, pandas 2.3.1, OS: debian trixie

tests/test_ephys_extractor.py: 4 warnings
tests/test_mies_nwb_pipeline_output.py: 126 warnings
tests/test_run_feature_vector.py: 94 warnings
  /home/thomas/devel/ipfx/ipfx/feature_extractor.py:195: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!
  You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
  A typical example is when you are setting values in a column of a DataFrame, like:
  
  df["col"][row_indexer] = value
  
  Use `df.loc[row_indexer, "col"] = values` instead, to perform the assignment in a single step and ensure this keeps updating the original `df`.
  
  See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  
    spikes_df["upstroke_downstroke_ratio"] = spikes_df["upstroke"] / -spikes_df["downstroke"]

tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Pvalb-IRES-Cre;Ai14(IVSCC)-165172.05.02/pipeline_input.json-./tests/data/specimens/Pvalb-IRES-Cre;Ai14(IVSCC)-165172.05.02/pipeline_output.json]
tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Vip-IRES-Cre;Ai14-331294.04.01.01/pipeline_input.json-./tests/data/specimens/Vip-IRES-Cre;Ai14-331294.04.01.01/pipeline_output.json]
tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Ctgf-T2A-dgCre;Ai14-495723.05.02.01/pipeline_input.json-./tests/data/specimens/Ctgf-T2A-dgCre;Ai14-495723.05.02.01/pipeline_output.json]
  /home/thomas/devel/ipfx/ipfx/feature_record.py:80: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!
  You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
  A typical example is when you are setting values in a column of a DataFrame, like:
  
  df["col"][row_indexer] = value
  
  Use `df.loc[row_indexer, "col"] = values` instead, to perform the assignment in a single step and ensure this keeps updating the original `df`.
  
  See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  
    sweep_table['peak_deflection'] = pd.Series(pds)

tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Pvalb-IRES-Cre;Ai14(IVSCC)-165172.05.02/pipeline_input.json-./tests/data/specimens/Pvalb-IRES-Cre;Ai14(IVSCC)-165172.05.02/pipeline_output.json]
tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Vip-IRES-Cre;Ai14-331294.04.01.01/pipeline_input.json-./tests/data/specimens/Vip-IRES-Cre;Ai14-331294.04.01.01/pipeline_output.json]
tests/test_mies_nwb_pipeline_output.py::test_mies_nwb_pipeline_output[./tests/data/specimens/Ctgf-T2A-dgCre;Ai14-495723.05.02.01/pipeline_input.json-./tests/data/specimens/Ctgf-T2A-dgCre;Ai14-495723.05.02.01/pipeline_output.json]
  /home/thomas/devel/ipfx/ipfx/feature_record.py:81: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!
  You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
  A typical example is when you are setting values in a column of a DataFrame, like:
  
  df["col"][row_indexer] = value
  
  Use `df.loc[row_indexer, "col"] = values` instead, to perform the assignment in a single step and ensure this keeps updating the original `df`.
  
  See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  
    sweep_table['num_spikes'] = pd.Series(num_spikes)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions