Skip to content

BUG: DataFrame quantile with only datetime dtypes should provide better error message #7308

@TomAugspurger

Description

@TomAugspurger
In [41]: df = DataFrame({"A": [1, 2, 3], "B": [2, 3, 4]}) In [42]: df['C'] = pd.date_range('2014-01-01', periods=3, freq='m') In [43]: df Out[43]: A B C 0 1 2 2014-01-31 1 2 3 2014-02-28 2 3 4 2014-03-31 In [44]: df[['C']].quantile(.5) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-44-1e5bdc20c0ca> in <module>() ----> 1 df[['C']].quantile(.5) /Users/tom/Envs/pandas-dev/lib/python2.7/site-packages/pandas/pandas/core/frame.pyc in quantile(self, q, axis, numeric_only) 4192 quantiles = [[f(vals, x) for x in per] 4193 for (_, vals) in data.iteritems()] -> 4194 result = DataFrame(quantiles, index=data._info_axis, columns=q).T 4195 if len(is_dt_col) > 0: 4196 result[is_dt_col] = result[is_dt_col].applymap(lib.Timestamp) /Users/tom/Envs/pandas-dev/lib/python2.7/site-packages/pandas/pandas/core/frame.pyc in __init__(self, data, index, columns, dtype, copy) 253 else: 254 mgr = self._init_ndarray(data, index, columns, dtype=dtype, --> 255 copy=copy) 256 elif isinstance(data, collections.Iterator): 257 raise TypeError("data argument can't be an iterator") /Users/tom/Envs/pandas-dev/lib/python2.7/site-packages/pandas/pandas/core/frame.pyc in _init_ndarray(self, values, index, columns, dtype, copy) 365 columns = _ensure_index(columns) 366 --> 367 return create_block_manager_from_blocks([values.T], [columns, index]) 368 369 @property /Users/tom/Envs/pandas-dev/lib/python2.7/site-packages/pandas/pandas/core/internals.pyc in create_block_manager_from_blocks(blocks, axes) 3183 blocks = [getattr(b, 'values', b) for b in blocks] 3184 tot_items = sum(b.shape[0] for b in blocks) -> 3185 construction_error(tot_items, blocks[0].shape[1:], axes, e) 3186 3187 /Users/tom/Envs/pandas-dev/lib/python2.7/site-packages/pandas/pandas/core/internals.pyc in construction_error(tot_items, block_shape, axes, e) 3164 raise e 3165 raise ValueError("Shape of passed values is {0}, indices imply {1}".format( -> 3166 passed,implied)) 3167 3168 ValueError: Shape of passed values is (0, 0), indices imply (1, 0)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions