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

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

Comments

@szli
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

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 http://stackoverflow.com/questions/14390224/reshape-of-pandas-series

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

@jreback

This comment has been minimized.

Copy link
Contributor

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))
Out[4]: 
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

@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2013

@y-p seems reasonable?

@ghost

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
Projects
None yet
2 participants
You can’t perform that action at this time.