Is a += b different than a = a+b?

Viewed 40

I think because pandas return a view of a dataframe when you manipulate a column out of your DataFrame it will affect on your original DataFrame but when i run first code it changes the column as it should but in second one it wont and i cant explain why ?! can anyone explain this to me ?

costs = df['Cost']
costs += 2
costs = df['Cost']
costs = costs + 2

thanks in advance

0 Answers
Related