-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Timestamp.floor() method not able to handle DST change in local time #44287
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
It appears the
|
Your example is producing the desired result, but the argument should not be needed in this case; there is no ambiguity here. And its quite a hassle to manually check if time is in DST or not when working with a large timeseries dataset... |
The flooring is done in local time, so |
The timestamp includes timezone information, so I would expect that to be taken into account, but I understand its not. Is that something that could potentially be improved? |
@m-kremer once u floor the time it's not clear which fold it's in and the result could be 2am or 1am; it's a user decision here |
That's not true if you would take tz info into account:
No ambiguity here... |
@m-kremer and sure for a subset of operations this may actually work. but as a general rule, e.g. arithmetic (+/-) and rounding operations you inevitably get to an ambiguous state because working with a timezone in an operation has so many edge cases. The general rule is easy to understand & test (operate in local non-tz aware time) |
Thanks @jreback, now I better understand why its working this way. This issue can be closed... :) |
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
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
The text was updated successfully, but these errors were encountered: