It is a relatively simple problem that is driving me crazy;
When I try to sort two data frames below df1 and df2 in a for loop, it doesn't give any error. However, when I print them, they are not sorted at all.
d={"a":[1,6,2,4,3],
"b":[1,2,3,4,5]}
k={"a":[7,12,8,11,9],
"d":[1,2,3,4,5]}
df1=pd.DataFrame(d)
df2=pd.DataFrame(k)
all_data=[df1,df2]
for data in all_data:
data=data.sort_values(by=["a"])
But, when you add inplace parameter, it saves the change. I thought using inplace=True parameter and assigning to the "data" variable was equivalent. Can you help me understand the logic behind this?