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
Closed

BUG? Reshaping a Series #2719

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

Comments

@szli
Copy link

szli 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
Copy link
Contributor

jreback 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 as completed Mar 21, 2013
@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

@y-p seems reasonable?

@ghost
Copy link

ghost 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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants