bigframes.pandas.DataFrame.copy#
- DataFrame.copy()→DataFrame[source]#
Make a copy of this object’s indices and data.
A new object will be created with a copy of the calling object’s dataand indices. Modifications to the data or indices of the copy will notbe reflected in the original object.
Examples:
Modification in the original Series will not affect the copy Series:
>>>s=bpd.Series([1,2],index=["a","b"])>>>sa 1b 2dtype: Int64
>>>s_copy=s.copy()>>>s_copya 1b 2dtype: Int64
>>>s.loc['b']=22>>>sa 1b 22dtype: Int64>>>s_copya 1b 2dtype: Int64
Modification in the original DataFrame will not affect the copy DataFrame:
>>>df=bpd.DataFrame({'a':[1,3],'b':[2,4]})>>>df a b0 1 21 3 4[2 rows x 2 columns]
>>>df_copy=df.copy()>>>df_copy a b0 1 21 3 4[2 rows x 2 columns]
>>>df.loc[df["b"]==2,"b"]=22>>>df a b0 1 221 3 4[2 rows x 2 columns]>>>df_copy a b0 1 21 3 4[2 rows x 2 columns]
- Returns:
Object type matches caller.
- Return type:
On this page