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

BUG? Reshaping a Series #2719

szli opened this issue Jan 21, 2013 · 3 comments · Fixed by #3127


Copy link

commented Jan 21, 2013

It looks to me like a bug in pandas.Series.

a = pd.Series([1,2,3,4])
b = a.reshape(2,2)

b has type Series but can not be displayed, the last statement gives exception, very lengthy, the last line is "TypeError: %d format: a number is required, not numpy.ndarray". b.shape returns (2,2), which contradicts its type Series. I am guessing perhaps pandas.Series does not implement reshape function and I am calling the version from np.array. I am at pandas 0.9.1. Some discussion on stackoverflow is here

If it does not make sense to reshape a Series, should it throw an exception?


This comment has been minimized.

Copy link

commented Mar 21, 2013

Fixed in #3127

You are specifing invalid input here, I think you want (2,2) as input where you will get back an ndarray
(as a 2-d reshape is not allowed)

In [2]: a = pd.Series([1,2,3,4])

In [4]: a.reshape((2,2))
array([[1, 2],
       [3, 4]])

In [5]: a.reshape(2,2)
TypeError: must specify a tuple / singular length to reshape

@jreback jreback closed this Mar 21, 2013


This comment has been minimized.

Copy link

commented Mar 21, 2013

@y-p seems reasonable?


This comment has been minimized.

Copy link

commented Mar 21, 2013

very much so.

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.