inplace operation for Series causes reappearance popped column · Issue #10912 · pandas-dev/pandas (original) (raw)
Hi, Thanks for all efforts for the great tool!
I've found a strange behavior like this...
In [1]: a = pd.DataFrame([[1,2,3],[4,5,6]], columns=['A','B','C'], index=['X','Y'])
In [2]: a Out[2]: A B C X 1 2 3 Y 4 5 6
In [3]: b = a.pop('B')
In [4]: a Out[4]: A C X 1 3 Y 4 6
In [5]: b Out[5]: X 2 Y 5 Name: B, dtype: int64
In [6]: b += 1
In [7]: a # Why does a popped column "B" appear again? Out[7]: A C B X 1 3 3 Y 4 6 6
In [8]: b Out[8]: X 3 Y 6 Name: B, dtype: int64
Is it a bug of pandas?
This behavior can be avoided by using b = b+1
instead of implace operations.