0

I am very surprise of a mechanism in pandas and can't find doc & info about it as I don't know how it's called: Is it normal that you can 'indirectly' make changes to a DataFrame ?
If I Have :

df1

Out[1]:
   A  B
0  A  10
1  B  20
2  C  30

And I do :

df2 = df1
df2['C'] = df2['B']
df1

Out[2]:
     A  B  C
  0  A  10 10
  1  B  20 20
  2  C  30 30

I just don't get why is df1 changed ? I'm only adding a column to df2 right ?

Matthieu
  • 15
  • 4

0 Answers0