Skip to content

BUG: Fix Panel instance variable namespace issue GH3440 #4459

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

Merged
merged 1 commit into from
Aug 5, 2013

Conversation

danbirken
Copy link
Contributor

The change is minor but so easy I thought I'd submit it: If you switch the list comprehensions to generators, it sidesteps leaking the temporary variables into the class variable scope.

This will be microscopically slower, but they are just class variables so it really doesn't matter.
fixes #3440

https://travis-ci.org/danbirken/pandas/builds/9836459

import numpy as np
from pandas import DataFrame, Panel

df0 = DataFrame(np.zeros([3,4]))
df1 = DataFrame(np.ones([3,4]))

p = Panel({'a':df0, 'b':df1})

In [1]: p.a
Out[1]:
   0  1  2  3
0  0  0  0  0
1  0  0  0  0
2  0  0  0  0

In [2]: p.b
Out[2]:
   0  1  2  3
0  1  1  1  1
1  1  1  1  1
2  1  1  1  1

@cpcloud
Copy link
Member

cpcloud commented Aug 5, 2013

@danbirken can u add a test? thx

@danbirken
Copy link
Contributor Author

There you go

Travis: https://travis-ci.org/danbirken/pandas/builds/9843789

@cpcloud
Copy link
Member

cpcloud commented Aug 5, 2013

@danbirken sweet thanks!

@cpcloud
Copy link
Member

cpcloud commented Aug 5, 2013

@jreback will this be fixed in #3482?

@jreback
Copy link
Contributor

jreback commented Aug 5, 2013

I think this fix is fine

cpcloud added a commit that referenced this pull request Aug 5, 2013
BUG: Fix Panel instance variable namespace issue GH3440
@cpcloud cpcloud merged commit 5d922b7 into pandas-dev:master Aug 5, 2013
@cpcloud
Copy link
Member

cpcloud commented Aug 5, 2013

@danbirken thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panel attribute naming conflict if item is named 'a'
3 participants