Skip to content

Commit 400fd2d

Browse files
committed
BUG: fix plotting of dup indexed objects
1 parent b23995f commit 400fd2d

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ pandas 0.13
125125
(:issue:`4455`)
126126
- Fixed Panel attribute naming conflict if item is named 'a'
127127
(:issue:`3440`)
128+
- Fixed an issue where duplicate indexes were raising when plotting
129+
(:issue:`4486`)
128130

129131
pandas 0.12
130132
===========

pandas/core/series.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ def _ixs(self, i, axis=0):
602602
else:
603603
return _index.get_value_at(self, i)
604604

605-
606605
@property
607606
def _is_mixed_type(self):
608607
return False
@@ -2646,8 +2645,10 @@ def reindex(self, index=None, method=None, level=None, fill_value=pa.NA,
26462645
level=level, limit=limit,
26472646
takeable=takeable)
26482647

2649-
# GH4246 (dispatch to a common method with frame to handle possibly duplicate index)
2650-
return self._reindex_with_indexers(new_index, indexer, copy=copy, fill_value=fill_value)
2648+
# GH4246 (dispatch to a common method with frame to handle possibly
2649+
# duplicate index)
2650+
return self._reindex_with_indexers(new_index, indexer, copy=copy,
2651+
fill_value=fill_value)
26512652

26522653
def _reindex_with_indexers(self, index, indexer, copy, fill_value):
26532654
new_values = com.take_1d(self.values, indexer, fill_value=fill_value)

pandas/tests/test_graphics.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import string
44
import unittest
55

6-
from datetime import datetime, date
6+
from datetime import datetime, date, timedelta
77

88
from pandas import Series, DataFrame, MultiIndex, PeriodIndex, date_range
99
from pandas.compat import range, lrange, StringIO, lmap, lzip, u, zip
@@ -309,6 +309,16 @@ def test_invalid_kind(self):
309309
s = Series([1, 2])
310310
self.assertRaises(ValueError, s.plot, kind='aasdf')
311311

312+
@slow
313+
def test_dup_datetime_index_plot(self):
314+
dr1 = date_range('1/1/2009', periods=4)
315+
dr2 = date_range('1/2/2009', periods=4)
316+
index = dr1.append(dr2)
317+
values = randn(index.size)
318+
s = Series(values, index=index)
319+
_check_plot_works(s.plot)
320+
321+
312322

313323
class TestDataFramePlots(unittest.TestCase):
314324

pandas/tools/plotting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def _get_xticks(self, convert_period=False):
10411041
"""
10421042
x = index._mpl_repr()
10431043
elif is_datetype:
1044-
self.data = self.data.reindex(index=index.order())
1044+
self.data = self.data.sort_index()
10451045
x = self.data.index._mpl_repr()
10461046
else:
10471047
self._need_to_set_index = True

0 commit comments

Comments
 (0)