Skip to content

Commit 3ede37a

Browse files
committed
Move feature test to new method, add to whatsnew
Also fix minor bug due to a misnamed var that both the test and pyflakes missed
1 parent 756e8d8 commit 3ede37a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/source/whatsnew/v0.20.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ Other Enhancements
371371
- :func:`MultiIndex.remove_unused_levels` has been added to facilitate :ref:`removing unused levels <advanced.shown_levels>`. (:issue:`15694`)
372372
- ``pd.read_csv()`` will now raise a ``ParserError`` error whenever any parsing error occurs (:issue:`15913`, :issue:`15925`)
373373
- ``pd.read_csv()`` now supports the ``error_bad_lines`` and ``warn_bad_lines`` arguments for the Python parser (:issue:`15925`)
374+
- ``pd.read_csv()`` will now raise a ``csv.Error`` error whenever an end-of-file character is encountered in the middle of a data row (:issue:`15913`)
375+
- ``parallel_coordinates()`` now has a ``sort_labels`` keyword arg that sorts class labels and the colours assigned to them (:issue:`15908`)
374376

375377

376378
.. _ISO 8601 duration: https://en.wikipedia.org/wiki/ISO_8601#Durations

pandas/tests/plotting/test_misc.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,16 @@ def test_parallel_coordinates(self):
241241
with tm.assert_produces_warning(FutureWarning):
242242
parallel_coordinates(df, 'Name', colors=colors)
243243

244+
def test_parallel_coordinates_with_sorted_labels(self):
245+
""" For #15908 """
246+
from pandas.tools.plotting import parallel_coordinates
247+
244248
df = DataFrame({"feat": [i for i in range(30)],
245249
"class": [2 for _ in range(10)] +
246250
[3 for _ in range(10)] +
247251
[1 for _ in range(10)]})
248252
ax = parallel_coordinates(df, 'class', sort_labels=True)
249-
polylines, lables = ax.get_legend_handles_labels()
253+
polylines, labels = ax.get_legend_handles_labels()
250254
color_label_tuples = \
251255
zip([polyline.get_color() for polyline in polylines], labels)
252256
ordered_color_label_tuples = sorted(color_label_tuples,

pandas/tools/plotting.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,11 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
719719
If true, vertical lines will be added at each xtick
720720
axvlines_kwds: keywords, optional
721721
Options to be passed to axvline method for vertical lines
722-
sort_labels: bool, optional
722+
sort_labels: bool, False
723723
Sort class_column labels, useful when assigning colours
724+
725+
.. versionadded:: 0.20.0
726+
724727
kwds: keywords
725728
Options to pass to matplotlib plotting method
726729
@@ -779,6 +782,7 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
779782

780783
if sort_labels is True:
781784
classes = sorted(classes)
785+
color_values = sorted(color_values)
782786
colors = dict(zip(classes, color_values))
783787

784788
for i in range(n):

0 commit comments

Comments
 (0)