From 43791f98416974a5d240338601265e1d57dad3c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 22:33:29 +0000 Subject: [PATCH 1/4] Initial plan From 652f610d978e82a37e1b55f18c3d3e40f8fb7bed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 22:40:24 +0000 Subject: [PATCH 2/4] Fix pandas FutureWarning: Replace chained assignment with .loc syntax in icephys.py Co-authored-by: rly <310197+rly@users.noreply.github.com> --- src/pynwb/icephys.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index 0a1493f08..4c37eadc1 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -746,14 +746,14 @@ def to_dataframe(self, **kwargs): """Convert the collection of tables to a single pandas DataFrame""" res = super().to_dataframe(ignore_category_ids=getargs('ignore_category_ids', kwargs)) if getargs('electrode_refs_as_objectids', kwargs): - res[('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]] + res.loc[:, ('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]] if getargs('stimulus_refs_as_objectids', kwargs): - res[('stimuli', 'stimulus')] = \ + res.loc[:, ('stimuli', 'stimulus')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) for e in res[('stimuli', 'stimulus')]] if getargs('response_refs_as_objectids', kwargs): - res[('responses', 'response')] = \ + res.loc[:, ('responses', 'response')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) for e in res[('responses', 'response')]] From a0e1ecc0b5bd10c674c7a32dcef47c0373b983c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 23:50:20 +0000 Subject: [PATCH 3/4] Revert pandas .loc fix due to test failures, investigate proper solution Co-authored-by: rly <310197+rly@users.noreply.github.com> --- src/pynwb/icephys.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index 4c37eadc1..0a1493f08 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -746,14 +746,14 @@ def to_dataframe(self, **kwargs): """Convert the collection of tables to a single pandas DataFrame""" res = super().to_dataframe(ignore_category_ids=getargs('ignore_category_ids', kwargs)) if getargs('electrode_refs_as_objectids', kwargs): - res.loc[:, ('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]] + res[('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]] if getargs('stimulus_refs_as_objectids', kwargs): - res.loc[:, ('stimuli', 'stimulus')] = \ + res[('stimuli', 'stimulus')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) for e in res[('stimuli', 'stimulus')]] if getargs('response_refs_as_objectids', kwargs): - res.loc[:, ('responses', 'response')] = \ + res[('responses', 'response')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) for e in res[('responses', 'response')]] From e7c208d5fef52ccef1b6281cef0dabf16a8fe9cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 23:51:30 +0000 Subject: [PATCH 4/4] Fix pandas FutureWarning by copying columns before assignment Co-authored-by: rly <310197+rly@users.noreply.github.com> --- src/pynwb/icephys.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index 0a1493f08..a9599ac9c 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -746,17 +746,20 @@ def to_dataframe(self, **kwargs): """Convert the collection of tables to a single pandas DataFrame""" res = super().to_dataframe(ignore_category_ids=getargs('ignore_category_ids', kwargs)) if getargs('electrode_refs_as_objectids', kwargs): - res[('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]] + electrode_col = res[('electrodes', 'electrode')].copy() + res[('electrodes', 'electrode')] = [e.object_id for e in electrode_col] if getargs('stimulus_refs_as_objectids', kwargs): + stimulus_col = res[('stimuli', 'stimulus')].copy() res[('stimuli', 'stimulus')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) - for e in res[('stimuli', 'stimulus')]] + for e in stimulus_col] if getargs('response_refs_as_objectids', kwargs): + response_col = res[('responses', 'response')].copy() res[('responses', 'response')] = \ [e if e[2] is None else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id) - for e in res[('responses', 'response')]] + for e in response_col] return res