You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think df.copy() does what we want in the @copy_td decorator because it doesn't make an actual copy of array fields.
We will probably have to make recursive deep copy with something likepd.DataFrame(data=copy.deepcopy(df.values), index=df.index, columns=df.columns).
Unfortunately, it will be definitely slower and memory intensive, so we might have to think about those consequences later.
importcopydfa=df.copy(deep=True)
dfb=deepcopy(df)
dfc=pd.DataFrame(data=copy.deepcopy(df.values), index=df.index, columns=df.columns)
dfa.PMd_spikes[0][0, 0] =-1# changes the value in dfdfb.PMd_spikes[1][0, 0] =-1# changes the value in dfdfc.PMd_spikes[2][0, 0] =-1# leaves the value in df intact
The text was updated successfully, but these errors were encountered:
I agree that we should change @copy_td to do a full deep copy, just so there aren't any surprises later on. Regarding the memory usage and slowness, I suppose we could re-evaluate places where we use the copy_td decorator to ensure that we really need to use it, but it seems like it should be used most of the time, if we're going for non-destructive manipulations as intended.
I don't think
df.copy()
does what we want in the@copy_td
decorator because it doesn't make an actual copy of array fields.We will probably have to make recursive deep copy with something like
pd.DataFrame(data=copy.deepcopy(df.values), index=df.index, columns=df.columns)
.Unfortunately, it will be definitely slower and memory intensive, so we might have to think about those consequences later.
The text was updated successfully, but these errors were encountered: