[P/M/K] copy() & deepcopy()

copy() & deepcopy()

When we copy one column in a dataframe to use,we are usually talking about .deepcopy() – to take the copy as another new one. As for .copy(), it remains synchronization with the original column in dataframe.It means every action we put on the copy will do the same to the original column.
1

shallow_copy = data.loc[data['parentesco1'] == 1].copy()

2

deep_copy = data.loc[data['parentesco1'] == 1].deepcopy()

deep_copy = data.copy(deep=True)

猜你喜欢

转载自blog.csdn.net/qq_40820196/article/details/82418986