Skip to content

BUG: strange timeseries plot behavior #16461

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

Merged
merged 2 commits into from
May 24, 2017
Merged

BUG: strange timeseries plot behavior #16461

merged 2 commits into from
May 24, 2017

Conversation

huguesv
Copy link
Contributor

@huguesv huguesv commented May 23, 2017

I added a test with the simple repro at the top of bug #6608, which appears to be the missing piece for the bug to be closed.

I went back in time to a previous version of pandas, and I confirmed the issue.

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> import datetime
>>>
>>> s1 = pd.Series([1, 2, 3], index=[datetime.datetime(1995, 12, 31), datetime.datetime(2000, 12, 31), datetime.datetime(2005, 12, 31)])
>>> s2 = pd.Series([1, 2, 3], index=[datetime.datetime(1997, 12, 31), datetime.datetime(2003, 12, 31), datetime.datetime(2008, 12, 31)])
>>>
>>> ax = s1.plot()
>>> s2.plot(ax=ax)
<matplotlib.axes._subplots.AxesSubplot object at 0x04ECED10>
>>> s1.plot(ax=ax)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tools\plotting.py", line 1829, in plot_series
    plot_obj.generate()
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tools\plotting.py", line 905, in generate
    self._make_plot()
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tools\plotting.py", line 1317, in _make_plot
    self._make_ts_plot(data, **self.kwds)
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tools\plotting.py", line 1388, in _make_ts_plot
    _plot(data, 0, ax, label, self.style, **kwds)
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tools\plotting.py", line 1372, in _plot
    style=style, **kwds)
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tseries\plotting.py", line 82, in tsplot
    left, right = _get_xlim(ax.get_lines())
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\tseries\plotting.py", line 226, in _get_xlim
    left = min(x[0].ordinal, left)
AttributeError: 'datetime.datetime' object has no attribute 'ordinal'
>>> print(pd.__version__)
0.13.1
>>>

@@ -434,6 +434,22 @@ def test_hist_no_overlap(self):
assert len(axes) == 2

@slow
def test_overlapping_datetime(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind moving this to pandas/tests/plotting/test_datetimelike.py? Seems to fit a bit better there.

@TomAugspurger TomAugspurger added the Visualization plotting label May 23, 2017
@TomAugspurger TomAugspurger added this to the 0.21.0 milestone May 23, 2017
@codecov
Copy link

codecov bot commented May 23, 2017

Codecov Report

Merging #16461 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16461      +/-   ##
==========================================
+ Coverage   90.42%   90.42%   +<.01%     
==========================================
  Files         161      161              
  Lines       51024    51027       +3     
==========================================
+ Hits        46139    46142       +3     
  Misses       4885     4885
Flag Coverage Δ
#multiple 88.26% <ø> (ø) ⬆️
#single 40.17% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/reshape/reshape.py 99.28% <0%> (ø) ⬆️
pandas/io/excel.py 62.31% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92372c7...3fe6d64. Read the comment docs.

@jreback jreback changed the title Add test for bug #6608 BUG: strange timeseries plot behavior May 24, 2017
@jreback
Copy link
Contributor

jreback commented May 24, 2017

lgtm (failure in CI is already resolved in master).

@TomAugspurger this is just a validation test?

@TomAugspurger
Copy link
Contributor

@TomAugspurger this is just a validation test?

yeah, it was accidentally fixed somewhere along the way, but didn't have a regression test

@jreback jreback merged commit b0038ac into pandas-dev:master May 24, 2017
@rosnfeld
Copy link
Contributor

@huguesv thanks for taking care of this! (I had meant to but never got around to it, so much appreciated)

stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants