diff --git a/doc/source/release.rst b/doc/source/release.rst index 35f422ccad9dc..92822e3038545 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -125,6 +125,8 @@ pandas 0.13 (:issue:`4455`) - Fixed Panel attribute naming conflict if item is named 'a' (:issue:`3440`) + - Fixed an issue where duplicate indexes were raising when plotting + (:issue:`4486`) pandas 0.12 =========== diff --git a/pandas/core/series.py b/pandas/core/series.py index 10b03ccd3a310..4899c53ad64b5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -602,7 +602,6 @@ def _ixs(self, i, axis=0): else: return _index.get_value_at(self, i) - @property def _is_mixed_type(self): return False @@ -2646,8 +2645,10 @@ def reindex(self, index=None, method=None, level=None, fill_value=pa.NA, level=level, limit=limit, takeable=takeable) - # GH4246 (dispatch to a common method with frame to handle possibly duplicate index) - return self._reindex_with_indexers(new_index, indexer, copy=copy, fill_value=fill_value) + # GH4246 (dispatch to a common method with frame to handle possibly + # duplicate index) + return self._reindex_with_indexers(new_index, indexer, copy=copy, + fill_value=fill_value) def _reindex_with_indexers(self, index, indexer, copy, fill_value): new_values = com.take_1d(self.values, indexer, fill_value=fill_value) diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index faaac1cbb5419..3e74b71441410 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -3,7 +3,7 @@ import string import unittest -from datetime import datetime, date +from datetime import datetime, date, timedelta from pandas import Series, DataFrame, MultiIndex, PeriodIndex, date_range from pandas.compat import range, lrange, StringIO, lmap, lzip, u, zip @@ -309,6 +309,16 @@ def test_invalid_kind(self): s = Series([1, 2]) self.assertRaises(ValueError, s.plot, kind='aasdf') + @slow + def test_dup_datetime_index_plot(self): + dr1 = date_range('1/1/2009', periods=4) + dr2 = date_range('1/2/2009', periods=4) + index = dr1.append(dr2) + values = randn(index.size) + s = Series(values, index=index) + _check_plot_works(s.plot) + + class TestDataFramePlots(unittest.TestCase): diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index 5deff90244135..9ae88c071eb27 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -1041,7 +1041,7 @@ def _get_xticks(self, convert_period=False): """ x = index._mpl_repr() elif is_datetype: - self.data = self.data.reindex(index=index.order()) + self.data = self.data.sort_index() x = self.data.index._mpl_repr() else: self._need_to_set_index = True