- DataFrame.copy(deep: bool = True) Self #
Make a copy of this object’s indices and data.
deep=True(default), a new object will be created with a copy of the calling object’s data and indices. Modifications to the data or indices of the copy will not be reflected in the original object (see notes below). When
deep=False, a new object will be created without copying the calling object’s data or index (only references to the data and index are copied). Any changes to the data of the original will be reflected in the shallow copy (and vice versa).
- deepbool, default True
Make a deep copy, including a copy of the data and the indices. With
deep=Falseneither the indices nor the data are copied.
- copySeries or DataFrame
Object type matches caller.
>>> s = cudf.Series([1, 2], index=["a", "b"]) >>> s a 1 b 2 dtype: int64 >>> s_copy = s.copy() >>> s_copy a 1 b 2 dtype: int64
Shallow copy versus default (deep) copy:
>>> s = cudf.Series([1, 2], index=["a", "b"]) >>> deep = s.copy() >>> shallow = s.copy(deep=False)
Updates to the data shared by shallow copy and original is reflected in both; deep copy remains unchanged.
>>> s['a'] = 3 >>> shallow['b'] = 4 >>> s a 3 b 4 dtype: int64 >>> shallow a 3 b 4 dtype: int64 >>> deep a 1 b 2 dtype: int64