-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas.floor('H') does not work with DST #14299
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
So on the reconversion which should be passing a boolean dst array.
you can compute it like this
So I would expose a Note that the above is not performant. This will have to be done in cython, like Pull-requests welcome |
cc @rockg |
Duplicate of #18946 |
Using floor on a DatetimeIndex that has a timezone with DST fails when converting the result back to the tz as there may be ambiguous time (see example below).
Expected Output
idx_h rounded to the hour
Actual Output
excepection raised when relocalizing the index after applying the rouding
Possible solution
The code to reconvert to local tz need to have 'ambiguous' defined and can use the original array of dst flags.
Lines 87-89 in ...\Lib\site-packages\pandas\tseries\base.py
to be replaced by
Lines 87-89 in ...\Lib\site-packages\pandas\tseries\base.py
Would it be also useful to have a DatetimeIndex.dst function to return a boolean array reuseable in tz_localize ?
Output of
pd.show_versions()
commit: None
python: 2.7.11.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.3
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.5
patsy: 0.4.0
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
The text was updated successfully, but these errors were encountered: