I have a Dataframe df1 with column 'a'. each row in column 'a' contains a 2d numpy array
> df1
a
0 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
1 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
2 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
3 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
I want to create a copy of this Dataframe and make changes to the 2d arrays without effecting the arrays in df1
So I took an explicit deep copy
df2 = df1.copy(deep=True)
> df2
a
0 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
1 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
2 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
3 [[10.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0,...
Now changing a value in the array in the first cell of df2 is also effecting df1
df2.loc[0,'a'][0,0] = 0
> df2
a
0 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
1 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
2 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
3 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
> df1
a
0 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
1 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
2 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
3 [[0.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, ...
How can I avoid this and what is the best way to make a copy of all sub objects of a Dataframe? Thanks