Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: df.plot() with FixedOffset timezones #17173
Code Sample, a copy-pastable example if possible
The following example will trigger an exception:
import pandas as pd import datetime data =  now = datetime.datetime.now(tz=datetime.timezone.utc) for i in range(10): data.append(dict(date=now + datetime.timedelta(days=i), data=i)) df = pd.DataFrame(data, index=[x['date'] for x in data]) df.plot()
This should fail with the error:
pandas/_libs/tslib.pyx in pandas._libs.tslib.dates_normalized (pandas/_libs/tslib.c:88136)() AttributeError: 'datetime.timezone' object has no attribute '_transition_info'
The "else" branch in this code will fail on instances of datetime.timezone which don't have a
The code on master looks like this:
else: trans, deltas, typ = _get_dst_info(tz) for i in range(n): # Adjust datetime64 timestamp, recompute datetimestruct pos = trans.searchsorted(stamps[i]) - 1 inf = tz._transition_info[pos] pandas_datetime_to_datetimestruct(stamps[i] + deltas[pos], PANDAS_FR_ns, &dts) if (dts.hour + dts.min + dts.sec + dts.us) > 0: return False
The problem is the setting of
I'd expect to be able to plot off timestamps which use datetime.timezone.utc as their timezone.
Actually this is more of an issue with FixedOffset timezones now.
changed the title
tslib.dates_normalized() depends on internal pytz API (support datetime.timezone objects)
Feb 3, 2019
I don't think the following lines are needed since we handle datetime.timezone instances now.