Skip to content

inplace operation for Series causes reappearance popped column #10912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
s-wakaba opened this issue Aug 27, 2015 · 1 comment · Fixed by #10922
Closed

inplace operation for Series causes reappearance popped column #10912

s-wakaba opened this issue Aug 27, 2015 · 1 comment · Fixed by #10922
Labels
Bug Internals Related to non-user accessible pandas implementation
Milestone

Comments

@s-wakaba
Copy link

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.

@jreback
Copy link
Contributor

jreback commented Aug 27, 2015

I think the cacher is somehow getting updated here.

@jreback jreback added Bug Prio-high Internals Related to non-user accessible pandas implementation labels Aug 27, 2015
@jreback jreback added this to the 0.17.0 milestone Aug 27, 2015
jreback added a commit that referenced this issue Aug 28, 2015
BUG: Bug in clearing the cache on DataFrame.pop and a subsequent inplace op #10912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants