diff --git a/RELEASE.rst b/RELEASE.rst index a33fad69fb3c1..c1fa30e23bc5a 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -201,6 +201,7 @@ pandas 0.11.0 - Fixed missing tick bars on scatter_matrix plot (GH3063_) - Fixed bug in Timestamp(d,tz=foo) when d is date() rather then datetime() (GH2993_) - series.plot(kind='bar') now respects pylab color schem (GH3115_) + - Fixed bug in reshape if not passed correct input, now raises TypeError (GH2719_) .. _GH2758: https://github.com/pydata/pandas/issues/2758 .. _GH2809: https://github.com/pydata/pandas/issues/2809 @@ -220,6 +221,7 @@ pandas 0.11.0 .. _GH622: https://github.com/pydata/pandas/issues/622 .. _GH797: https://github.com/pydata/pandas/issues/797 .. _GH2681: https://github.com/pydata/pandas/issues/2681 +.. _GH2719: https://github.com/pydata/pandas/issues/2719 .. _GH2746: https://github.com/pydata/pandas/issues/2746 .. _GH2747: https://github.com/pydata/pandas/issues/2747 .. _GH2751: https://github.com/pydata/pandas/issues/2751 diff --git a/pandas/core/series.py b/pandas/core/series.py index 0c006d4c60904..53793d503403e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -923,6 +923,9 @@ def reshape(self, newshape, order='C'): """ See numpy.ndarray.reshape """ + if order not in ['C','F']: + raise TypeError("must specify a tuple / singular length to reshape") + if isinstance(newshape, tuple) and len(newshape) > 1: return self.values.reshape(newshape, order=order) else: diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 20c57ebbd0db6..fbbb48966f754 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -932,6 +932,10 @@ def test_reshape_non_2d(self): x = Series(np.random.random(201), name='x') self.assertRaises(TypeError, x.reshape, (len(x),)) + # GH 2719 + a = Series([1,2,3,4]) + self.assertRaises(TypeError,a.reshape, 2, 2) + def test_reshape_2d_return_array(self): x = Series(np.random.random(201), name='x') result = x.reshape((-1, 1))