Skip to content
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

UnboundLocalError when setting data to a Panel: "local variable 'mat' referenced before assignment" #452

andreas-h opened this issue Dec 6, 2011 · 1 comment


Copy link

commented Dec 6, 2011


the following code produces a UnboundLocalError when executed with pandas 0.6.0 / Python 2.7:

import datetime
import pandas
timeidx = pandas.DateRange(start=datetime.datetime(2009,1,1),
lons_coarse = np.linspace(-177.5, 177.5, 72)
lats_coarse = np.linspace(-87.5, 87.5, 36)
P = pandas.Panel(items=timeidx, major_axis=lons_coarse, minor_axis=lats_coarse)
P[datetime.datetime(2009,2,28)] = np.random.randn(72*36).reshape((72,36))

Maybe this is to be expected, but it's definitely not intuitive. Since both P[datetime.datetime(2009,2,28)] and np.random.randn(72*36).reshape((72,36)) have shape (72,36), I would expect this to work.

Until it does, what would be the way to do this?


This comment has been minimized.

Copy link

commented Dec 8, 2011

fixed in the above commit

@wesm wesm closed this Dec 8, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.