-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Can't floor timezone-aware Timestamp
#46757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Given https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DatetimeIndex.floor.html
And a wall time of
|
Thanks @mroeschke for your answer. I can see that you are able to dictate which of the My point is even stronger: the original (I am not sure how universal this is. But then again, I'm not sure what I would even expect to get from flooring this to |
Given that 2:00 is floored relative to the wall time and not the absolute time, i.e. I somewhat understand on the surface implementation that should feel like a no-op, but I guess this is an unfortunate edge case of being consistent that rounding is assumed to be relative to wall time |
The UTC-offset ( If the constraint of the current implementation - namely, that this UTC-offset will be ignored - is set in stone, then yes, I agree with you, and the timestamp is ambiguous. After all, we get I can imagine an additional check in the flooring method, where the UTC-offset is not ignored, and instead used to determine the correct return value, in case just using the wall time is ambiguous. And the But from your link I see that someone else already unsuccessfully made that case, so we can close this as a duplicate. |
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
Issue Description
The timestamp in the above example is well-defined having both a timezone (Europe/Berlin) and a UTC-offset (+2). Flooring it to the nearest full (quarter)hour should be possible, but raises an error instead.
Expected Behavior
I don't think the result of the flooring operation is ambiguous. The method should return
ts
.I've posted a proposal for a partial solution here.
Installed Versions
INSTALLED VERSIONS
commit : 06d2301
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.4.1
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : None
pytest : 7.1.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.1.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
sqlalchemy : 1.4.32
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: