Skip to content

BUG: .max() gives wrong answer for non-nanosecond datetimeindex #50716

@MarcoGorelli

Description

@MarcoGorelli
Member

Pandas version checks

  • I have checked that this issue has not already been reported.

    I have confirmed this bug exists on the latest version of pandas.

    I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

In [3]: DatetimeIndex(['2015-09-22 08:31:00', '2015-09-19 09:02:00','2015-09-19 14:14:00'], dtype='datetime64[s]').as_
   ...: unit('s').max()
Out[3]: Timestamp('1970-01-01 00:00:01')

Issue Description

should give '2015-09-19 14:14:00' Timestamp

Expected Behavior

should give '2015-09-19 14:14:00' Timestamp

Installed Versions

INSTALLED VERSIONS

commit : ad91ead
python : 3.11.1.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 2.0.0.dev0+1157.gad91ead6de
numpy : 1.25.0.dev0+363.gbb2769e12
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.7.0
pip : 22.3.1
Cython : 0.29.33
pytest : 7.2.0
hypothesis : 6.52.1
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : None
qtpy : None
pyqt5 : None
None

Activity

added
DatetimeDatetime data dtype
Non-Nanodatetime64/timedelta64 with non-nanosecond resolution
on Jan 12, 2023
jbrockmendel

jbrockmendel commented on Jan 12, 2023

@jbrockmendel
Member

take

MarcoGorelli

MarcoGorelli commented on Jan 12, 2023

@MarcoGorelli
MemberAuthor

@jbrockmendel have you already started this? I'd just started a PR, but happy to let it go if you're already on it

jbrockmendel

jbrockmendel commented on Jan 12, 2023

@jbrockmendel
Member

go for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeNon-Nanodatetime64/timedelta64 with non-nanosecond resolution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @jbrockmendel@MarcoGorelli

      Issue actions

        BUG: .max() gives wrong answer for non-nanosecond datetimeindex · Issue #50716 · pandas-dev/pandas