Skip to content
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

ENH: Support dateutil.tz.tzrange objects #31694

Closed
Tux1 opened this issue Feb 5, 2020 · 3 comments
Closed

ENH: Support dateutil.tz.tzrange objects #31694

Tux1 opened this issue Feb 5, 2020 · 3 comments
Labels
Enhancement Timezones Timezone data dtype

Comments

@Tux1
Copy link
Contributor

Tux1 commented Feb 5, 2020

Code Sample, a copy-pastable example if possible

mytz = dateutil.tz.tzrange("EST", -18000, "EDT", -14400,
                  dateutil.relativedelta.relativedelta(hours=+2, month=4,
                                weekday=dateutil.relativedelta.SU(+1)),
                  dateutil.relativedelta.relativedelta(hours=+1, month=10,
                                weekday=dateutil.relativedelta.SU(-1)))
pd.to_datetime('20190204', utc=True).tz_convert(mytz)

AttributeError Traceback (most recent call last)
pandas_libs\tslibs\timezones.pyx in pandas._libs.tslibs.timezones.get_dst_info()

AttributeError: 'NoneType' object has no attribute 'total_seconds'
Exception ignored in: 'pandas._libs.tslibs.conversion.localize_tso'
Traceback (most recent call last):
File "pandas_libs\tslibs\timezones.pyx", line 220, in pandas._libs.tslibs.timezones.get_dst_info
AttributeError: 'NoneType' object has no attribute 'total_seconds'
Out[243]: Timestamp('2019-02-04 00:00:00')

Problem description

tz_convert fails on custom timezone with DST provided. Here is the example with dateutil but it would fail with any custom timezone with DST offset

Expected Output

Timestamp('2019-02-03 19:00:00-0500', tz='mytz')

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 0.25.1
numpy : 1.16.5
pytz : 2019.3
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.4.0
Cython : 0.29.13
pytest : 5.2.1
hypothesis : None
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : 1.2.1
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.9
tables : 3.5.2
xarray : 0.14.0
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.1

@Tux1 Tux1 changed the title tz_convert fails with custom timezone tz_convert fails with custom timezone Feb 5, 2020
@Tux1
Copy link
Contributor Author

Tux1 commented Feb 5, 2020

Actually it is more a new feature to implement. But since tzrange does not have transition list, I don't know how to do that...

@mroeschke mroeschke changed the title tz_convert fails with custom timezone ENH: Support dateutil.tz.tzrange objects Feb 5, 2020
@mroeschke mroeschke added Enhancement Timezones Timezone data dtype labels Feb 5, 2020
@jbrockmendel
Copy link
Member

In Localizer.__cinit__ we call get_dst_info(tz), which is wrong with this kind of tz. A few lines above that call is a check for elif is_tzlocal(tz) or is_zoneinfo(tz): and we need to amend that check so that this branch (and in general and un-recognized tzinfo) goes down that path.

@mroeschke
Copy link
Member

Thanks for the issue, but it appears this hasn't gotten traction in a while so closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

3 participants