I have a Pandas framework called pd and I retrieve the number of unique values ββin one of the columns of this data frame using the following command:
b = df.groupby('Region').size()
b is an object of the Pandas series and looks like this:
In [48]: b Out[48]: Region 0 8 1 25 11 1 2 41 3 23 4 15 5 35 6 24 7 27 8 50 9 55 N 10
I am trying to build a barchart of this series, however, I would like to sort it first based on the first column (because of this 11 between 1 and 2), which will be the x-axis labels. I tried passing the sort command, but sorts the series based on the values ββin the second column:
b.sort() In [48]: b Out[54]: Region 11 1 0 8 N 10 4 15 3 23 6 24 1 25 7 27 5 35 2 41 8 50 9 55
Well, is there a way to sort this series based on the first column?
source share