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
num2date ignoring tz in v1.5.0 #5543
Comments
attn @pganssle |
@brendene Can you provide a minimal example of the usage of this? |
I discovered this when using Pandas (0.17.1) and matplotlib (1.5.0) while trying to plot time-series data where the x-axis is timezone aware datetime. No matter what I did I could not change the x-axis to use a timezone other than UTC. Here is a simple example which I believe causes the plotting issue. Version 1.5.0 In [1]: import matplotlib.dates, datetime, pytz
In [2]: x = datetime.datetime.utcfromtimestamp(1448154154)
In [3]: y = matplotlib.dates.date2num(x)
In [4]: print matplotlib.dates.num2date(y), matplotlib.dates.num2date(y, tz=pytz.timezone("US/Eastern"))
2015-11-22 01:02:34+00:00 2015-11-22 01:02:34+00:00 Version 1.4.3 In [1]: import matplotlib.dates, datetime, pytz
In [2]: x = datetime.datetime.utcfromtimestamp(1448154154)
In [3]: y = matplotlib.dates.date2num(x)
In [4]: print matplotlib.dates.num2date(y), matplotlib.dates.num2date(y, tz=pytz.timezone("US/Eastern"))
2015-11-22 01:02:34+00:00 2015-11-21 20:02:34-05:00 |
Fix #5543: Handle timezone in num2date
The behavior of matplotlib.dates.num2date changed between stable versions 1.4.3 and 1.5.
In version 1.5 the implementation of helper function, _from_ordinalf ignores the tz argument and always returns datetimes in UTC.
In version 1.4.3 this is handled correctly.
The text was updated successfully, but these errors were encountered: