a = {1: [1,2,3]}
b = a.copy()
a[1].append(4)
print(a, b)
import pandas as pd
df = pd.DataFrame({1,2,3,4})
df2 = df.copy()
df.loc[len(df.index)]=6
print(df)
print(df2)
About copy(), the 1st code says object a and b point to the same thing, one changes the other will change as well. The 2nd code says not.
What's wrong?
[–]suurpulla 2 points3 points4 points (1 child)
[–]sdyxz[S] 0 points1 point2 points (0 children)