Skip to content
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

DatetimeIndex loses freq information if mask with ellipses #21282

Closed
ChadFulton opened this issue Jun 1, 2018 · 0 comments · Fixed by #24157
Closed

DatetimeIndex loses freq information if mask with ellipses #21282

ChadFulton opened this issue Jun 1, 2018 · 0 comments · Fixed by #24157
Milestone

Comments

@ChadFulton
Copy link

Code Sample, a copy-pastable example if possible

import pandas as pd
index = pd.DatetimeIndex(start='1990', end='1994', freq='AS')
print(index)
print(index[:])
print(index[...])

yields:

DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')
DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')
DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq=None)

Problem description

The frequency information in a DatetimeIndex is lost if all elements are selected via an ellipses.

(Note this also happens with e.g. index[:, ...] or with index[[True, True, True, True, True], ...]).

Expected Output

DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')
DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')
DatetimeIndex(['1990-01-01', '1991-01-01', '1992-01-01', '1993-01-01',
               '1994-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.0
pytest: 3.5.1
pip: 10.0.1
setuptools: 39.1.0
Cython: None
numpy: 1.14.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.4.0
sphinx: 1.7.4
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants