Skip to content

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

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

Closed
cottrell opened this issue Jul 3, 2015 · 1 comment
Labels
Bug Categorical Categorical Data Type
Milestone

Comments

@cottrell
Copy link
Contributor

cottrell commented Jul 3, 2015

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'
@jreback
Copy link
Contributor

jreback commented Jul 6, 2015

this is a dupe of #9416

@jreback jreback closed this as completed Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type
Projects
None yet
Development

No branches or pull requests

3 participants