I am relatively new to Python, Pandas, and plotting. I am looking to make a custom sort order in a pandas plot using a list, mapping, and sending them through to the plot function.
I am not "solid" on mapping or dict comprehensions. I've looked around a bit on Google and haven't found anything really clear - so any direction to helpful references would be much appreciated.
I have a dataframe that is the result of a groupby:
Exchange
AMEX 267
NYSE 2517
Nasdaq 2747
Name: Symbol, dtype: int64
The numerical column is 'Symbol' and the exchange listing is the index
When I do a straightforward pandas plot
my_plot = Exchange['Symbol'].plot(kind='bar')
I get this:
The columns are in the order of the rows in the dataframe (Amex, NYSE, Nasdaq) but I would like to present, left to right, NYSE, Nasdaq, and Amex. So a "sort" won't work.
There is another post:
that gets at this - but I just couldn't figure it out.
I feel like the solution is one step out of my reach. I think this is a very important concept to get down as it would help me considerably in visualizing data where the not-infrequent case of a custom row presentation in a chart is needed. I'm also hoping discussion here could help me better understand mapping as that seems to be very useful in many instances but I just can't seem to find the right on-line resource to explain it clearly.
Thank you in advance.