pynwb icon indicating copy to clipboard operation
pynwb copied to clipboard

[Bug]: FutureWarning from pandas with python 3.14 when running tests

Open t-b opened this issue 4 months ago • 2 comments

What happened?

When running the pynwb tests with Python 3.14.0rc2+ I get the following warnings:

tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
  /home/thomas/.venvs/ipfx-3.14-dev/lib/python3.14/site-packages/pynwb/icephys.py:749: 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
  
    res[('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]]

tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
  /home/thomas/.venvs/ipfx-3.14-dev/lib/python3.14/site-packages/pynwb/icephys.py:751: 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
  
    res[('stimuli', 'stimulus')] = \

tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
tests/unit/test_icephys_metadata_tables.py::IntracellularRecordingsTableTests::test_basic_write
  /home/thomas/.venvs/ipfx-3.14-dev/lib/python3.14/site-packages/pynwb/icephys.py:756: 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
  
    res[('responses', 'response')] = \

Steps to Reproduce

pytest tests

Traceback


Operating System

Linux

Python Executable

Python

Python Version

lower version (unsupported)

Package Versions

environment_for_issue.txt

Code of Conduct

t-b avatar Aug 19 '25 13:08 t-b

I could not choose a future not yet supported python version in the issue template, see also https://github.com/NeurodataWithoutBorders/pynwb/pull/2127.

t-b avatar Aug 19 '25 13:08 t-b

Thanks @t-b. It looks like there is no release date for pandas 3.0 yet, but we'll take a look at this.

rly avatar Aug 19 '25 22:08 rly