Description
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