Skip to content

.shift() on Categorical raises "'Categorical' object has no attribute 'flags'" #10495

Closed
@cottrell

Description

@cottrell

Not sure if this is related to #10324 .

Running master with python 3.4.3.

import pandas

values = ['a', 'b', 'c', 'd']
a = pandas.Series(values)
b = pandas.Series(values, dtype='category')

print(a.shift()) # ok
print(b.shift()) # error

Error looks like this:

$ python f.py
0    NaN
1      a
2      b
3      c
dtype: object
Traceback (most recent call last):
  File "f.py", line 8, in <module>
    print(b.shift()) # error
  File "/Users/davidcottrell/dev/pandas.git/pandas/core/series.py", line 2165, in shift
    axis=axis, **kwargs)
  File "/Users/davidcottrell/dev/pandas.git/pandas/core/generic.py", line 3688, in shift
    new_data = self._data.shift(periods=periods, axis=block_axis)
  File "/Users/davidcottrell/dev/pandas.git/pandas/core/internals.py", line 2498, in shift
    return self.apply('shift', **kwargs)
  File "/Users/davidcottrell/dev/pandas.git/pandas/core/internals.py", line 2462, in apply
    applied = getattr(b, f)(**kwargs)
  File "/Users/davidcottrell/dev/pandas.git/pandas/core/internals.py", line 890, in shift
    f_ordered = new_values.flags.f_contiguous
AttributeError: 'Categorical' object has no attribute 'flags'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions