BUG: when flooring, ambiguous parameter unnecessarily used (and raising Error) · Issue #49565 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd

ts = pd.Timestamp("2020-10-25 00:00", tz='Europe/Berlin')

This works:

ts.floor('H') # Timestamp('2020-10-25 00:00:00+0200', tz='Europe/Berlin')

But this gives an error:

ts.floor('H', ambiguous='infer') # ValueError: Cannot infer offset with only one time.

Issue Description

The value of the ambiguous parameter is used by the method, even if there is no ambiguity.

Expected Behavior

Both calls to the .floor method should give the same outcome.

Installed Versions

INSTALLED VERSIONS

commit : 91111fd
python : 3.9.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252

pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.2.2
Cython : None
pytest : 7.1.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.5.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
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
xlwt : None
zstandard : None
tzdata : None