Skip to content

BUG: DatetimeIndex.round needs ambiguous='infer', although nothing ambiguous is in the index #55864

@MarkusPic

Description

@MarkusPic

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

import pandas as pd
index = pd.date_range('2023-10-28', '2023-10-30', freq='30min', tz='Europe/Vienna')
freq = '1min'

index.round(freq)  # raises: AmbiguousTimeError: Cannot infer dst time from 2023-10-29 02:00:00, try using the 'ambiguous' argument

index.tz_convert('utc').round(freq).tz_convert(index.tz) # runs without problem

index.round(freq, ambiguous='infer')  # would also work, but I don't think there is anything ambiguous since a tz is present

Issue Description

index.round(freq)

raises: AmbiguousTimeError: Cannot infer dst time from 2023-10-29 02:00:00, try using the 'ambiguous' argument.

Although I don't think there is anything ambiguous since a timezone is present.

Expected Behavior

I would expect that the 'ambiguous' argument is not needed.

Installed Versions

INSTALLED VERSIONS

commit : a60ad39
python : 3.11.6.final.0
python-bits : 64
OS : Darwin
OS-release : 23.1.0
Version : Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.2
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.5.1
pip : 23.2.1
Cython : 3.0.2
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.17.2
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : 2023.7.0
fsspec : 2023.3.0
gcsfs : None
matplotlib : 3.8.0
numba : 0.57.1
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 12.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : 2.0.19
tables : None
tabulate : 0.9.0
xarray : 2023.8.0
xlrd : None
zstandard : None
tzdata : 2022.7
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions