Skip to content

Commit e7c208d

Browse files
Copilotrly
andcommitted
Fix pandas FutureWarning by copying columns before assignment
Co-authored-by: rly <[email protected]>
1 parent a0e1ecc commit e7c208d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pynwb/icephys.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,17 +746,20 @@ def to_dataframe(self, **kwargs):
746746
"""Convert the collection of tables to a single pandas DataFrame"""
747747
res = super().to_dataframe(ignore_category_ids=getargs('ignore_category_ids', kwargs))
748748
if getargs('electrode_refs_as_objectids', kwargs):
749-
res[('electrodes', 'electrode')] = [e.object_id for e in res[('electrodes', 'electrode')]]
749+
electrode_col = res[('electrodes', 'electrode')].copy()
750+
res[('electrodes', 'electrode')] = [e.object_id for e in electrode_col]
750751
if getargs('stimulus_refs_as_objectids', kwargs):
752+
stimulus_col = res[('stimuli', 'stimulus')].copy()
751753
res[('stimuli', 'stimulus')] = \
752754
[e if e[2] is None
753755
else TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id)
754-
for e in res[('stimuli', 'stimulus')]]
756+
for e in stimulus_col]
755757
if getargs('response_refs_as_objectids', kwargs):
758+
response_col = res[('responses', 'response')].copy()
756759
res[('responses', 'response')] = \
757760
[e if e[2] is None else
758761
TimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLE(e[0], e[1], e[2].object_id)
759-
for e in res[('responses', 'response')]]
762+
for e in response_col]
760763
return res
761764

762765

0 commit comments

Comments
 (0)