Skip to content

BUG: .dt accessor raises on a Series of Categorical Timestamps with repeats #19468

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
jschendel opened this issue Jan 30, 2018 · 1 comment
Closed
Labels
Bug Categorical Categorical Data Type Datetime Datetime data dtype
Milestone

Comments

@jschendel
Copy link
Member

Code Sample, a copy-pastable example if possible

On master:

In [2]: pd.__version__
Out[2]: '0.23.0.dev0+190.g238499a'

In [3]: dti = pd.DatetimeIndex(['20171111', '20181212']).repeat(2)

In [4]: s = pd.Series(pd.Categorical(dti))

In [5]: s
Out[5]:
0   2017-11-11
1   2017-11-11
2   2018-12-12
3   2018-12-12
dtype: category
Categories (2, datetime64[ns]): [2017-11-11, 2018-12-12]

In [6]: s.dt.year
---------------------------------------------------------------------------
ValueError: Wrong number of items passed 4, placement implies 2

Note that this works on 0.22.0:

In [2]: pd.__version__
Out[2]: '0.22.0'

In [3]: dti = pd.DatetimeIndex(['20171111', '20181212']).repeat(2)

In [4]: s = pd.Series(pd.Categorical(dti))

In [5]: s
Out[5]:
0   2017-11-11
1   2017-11-11
2   2018-12-12
3   2018-12-12
dtype: category
Categories (2, datetime64[ns]): [2017-11-11, 2018-12-12]

In [6]: s.dt.year
Out[6]:
0    2017
1    2017
2    2018
3    2018
dtype: int64

Problem description

Previously valid behavior now raises.

Expected Output

I'd expect the output on master to be the same as on 0.22.0.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: 238499a
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.0.dev0+190.g238499a
pytest: 3.1.2
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.13.3
scipy: 1.0.0
pyarrow: 0.6.0
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: None
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: 0.1.0
pandas_gbq: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

Most likely the extension accessor stuff. Looking into it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

2 participants