ValueError when trying to compute Quantile · Issue #14357 · pandas-dev/pandas (original) (raw)

In [7]: df = pd.DataFrame(np.random.randn(10, 2))

In [8]: df.iloc[1, 1] = np.nan

In [9]: df.quantile(.5)

ValueError Traceback (most recent call last) in () ----> 1 df.quantile(.5)

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas-0.19.0rc1+21.ge596cbf-py3.5-macosx-10.11-x86_64.egg/pandas/core/frame.py in quantile(self, q, axis, numeric_only, interpolation) 5152 axis=1, 5153 interpolation=interpolation, -> 5154 transposed=is_transposed) 5155 5156 if result.ndim == 2:

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas-0.19.0rc1+21.ge596cbf-py3.5-macosx-10.11-x86_64.egg/pandas/core/internals.py in quantile(self, **kwargs) 3142 3143 def quantile(self, **kwargs): -> 3144 return self.reduction('quantile', **kwargs) 3145 3146 def setitem(self, **kwargs):

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas-0.19.0rc1+21.ge596cbf-py3.5-macosx-10.11-x86_64.egg/pandas/core/internals.py in reduction(self, f, axis, consolidate, transposed, **kwargs) 3071 for b in self.blocks: 3072 kwargs['mgr'] = self -> 3073 axe, block = getattr(b, f)(axis=axis, **kwargs) 3074 3075 axes.append(axe)

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas-0.19.0rc1+21.ge596cbf-py3.5-macosx-10.11-x86_64.egg/pandas/core/internals.py in quantile(self, qs, interpolation, axis, mgr) 1325 values = _block_shape(values[~mask], ndim=self.ndim) 1326 if self.ndim > 1: -> 1327 values = values.reshape(result_shape) 1328 1329 from pandas import Float64Index

ValueError: total size of new array must be unchanged

original post follows


I have a simple dataframe that I created as follows:

df[df['Week of'] == week]

where week is a week name I'm filtering by

I have been taking the quartile values of this dataframe as follows:

df[df['Week of'] == week].quantile(.25)

However since the update to Pandas 0.19 I am receiving the error (this code worked fine before):

values = values.reshape(result_shape)
ValueError: total size of new array must be unchanged