Description
-
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 master branch of pandas.
Reproducible Example
import pandas as pd
# Example 1: Timestamp('2021-10-31 02:30:00+0200', tz='Europe/Amsterdam')
timestamp = (pd.to_datetime('2021-10-31 00:30:00')
.tz_localize('UTC')
.tz_convert('Europe/Amsterdam'))
ts_hour = timestamp.floor('60T')
# Returns: AmbiguousTimeError
# Expected: Timestamp('2021-10-31 02:00:00+0200', tz='Europe/Amsterdam')
# Example 2: Timestamp('2021-10-31 02:30:00+0100', tz='Europe/Amsterdam')
timestamp = (pd.to_datetime('2021-10-31 01:30:00')
.tz_localize('UTC')
.tz_convert('Europe/Amsterdam'))
ts_hour = timestamp.floor('60T')
# Returns: AmbiguousTimeError
# Expected: Timestamp('2021-10-31 02:00:00+0100', tz='Europe/Amsterdam')
Issue Description
The timestamp is in local time, so pandas should how enough information to know how to round it down to the whole hour. However, it does not recognize this and asks for an ambiguous argument.
Adding ambiguous=True does not provide the desired result.
Expected Behavior
See reproducible example
Installed Versions
INSTALLED VERSIONS
commit : 945c9ed
python : 3.9.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Dutch_Netherlands.1252
pandas : 1.3.4
numpy : 1.21.3
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 58.4.0
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.3
IPython : 7.29.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.2
numexpr : None
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : 1.4.13
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None