Georg Heiler Georg Heiler - 2 months ago 8
Python Question

Python sorted plot

I want to use seaborn to perform a

sns.barplot
where the values are ordered e.g. in ascending order.

In case the
order
parameter of seaborn is set the plot seems to duplicate the labels for all non-NaN labels.

Trying to pre-sort the values like
mydf.sort_values(['myValueField'], ascending=False)
does not change the result as seaborn does not seem to interpret it.

Answer

Do you save the changes by pd.sort_values? If not, probably you have to add the inplace keyword:

mydf.sort_values(['myValueField'], ascending=False, inplace=True)

Comments