Skip to content

Deep copy in copy_td #127

Open
Open
@bagibence

Description

@bagibence

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.

import copy
dfa = 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 df
dfb.PMd_spikes[1][0, 0] = -1 # changes the value in df
dfc.PMd_spikes[2][0, 0] = -1 # leaves the value in df intact

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