Skip to content

BUG: fix plotting of dup indexed objects #4492

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 1 commit into from
Aug 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):

Expand Down
2 changes: 1 addition & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down