Skip to content

Unclear DataFrame.info() range summary info for DatetimeIndex #31116

@Ircama

Description

@Ircama

Within DataFrame.info, the description of the DatetimeIndex of unsorted indexes might not be clear enough to users, because just showing the first and last element and not the "min date" to "max date" values.

Please check the following sample:

import pandas as pd dfs = [] for day in [30, 1, 2, 5]: idx = pd.date_range(f'2020-01-{day} 00:00:00', periods=1000, freq='s') dfs.append(pd.DataFrame({'count': range(len(idx)), 'date': idx})) df = pd.concat(dfs) df.set_index(['date'], inplace=True) df df.info() df.index.min() df.index.max()

Reated output is the following:

>>> df count date 2020-01-30 00:00:00 0 2020-01-30 00:00:01 1 2020-01-30 00:00:02 2 2020-01-30 00:00:03 3 2020-01-30 00:00:04 4 ... ... 2020-01-05 00:16:35 995 2020-01-05 00:16:36 996 2020-01-05 00:16:37 997 2020-01-05 00:16:38 998 2020-01-05 00:16:39 999 [4000 rows x 1 columns] >>> df.info() <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 4000 entries, 2020-01-30 00:00:00 to 2020-01-05 00:16:39 Data columns (total 1 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 count 4000 non-null int64 dtypes: int64(1) memory usage: 62.5 KB >>> df.index.min() Timestamp('2020-01-01 00:00:00') >>> df.index.max() Timestamp('2020-01-30 00:16:39') 

I would expect 2020-01-01 00:00:00 to 2020-01-30 00:16:39 (min and max range values for DatetimeIndex) and not 2020-01-30 00:00:00 to 2020-01-05 00:16:39 (first and last element).

In case, PR #31069 fixes the issue.

INSTALLED VERSIONS

commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-18362-Microsoft
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 0.25.1
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.6.0
Cython : 0.29.14
pytest : 5.3.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.1
bottleneck : None
fastparquet : 0.3.2
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
s3fs : None
scipy : 1.3.3
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions