python - How to apply custom column order to pandas boxplot? -


I can get a box plot of pay column in the penda dataframe ...

  Train.boxplot (column = 'predictionError', = 'range', sym = '')   

... but I can not understand how the index- Define the order on the 'Category' column - I want to place my own custom order according to another criteria:

  category_order_by_mean_salary = train.groupby ('category') ['salary' ]. Meaning () Order () Key ()   

How do I apply my custom column order to the boxplot column? (In addition to defaming column names with the prefix to emphasize the organization)

'Category' is a string column that has 27 specific values: ['Accounting & amp; Finance jobs', 'administration jobs', ...,' travel jobs'] . Therefore it can be easily focused on pd.Categorical.from_array ()

, pandas.tools.plotting.py: Boxplot () , which changes the column object without the permission to order:

  • a passthrough

  • which instantiates ...
  • which instantiates ...
  • I think I'm either panda (boxplot) Can I hack a custom version of, or access the object's interior?

    Edit: This question pandes ~ 0.13 Areas happened and probably recently (0.1 9+?) According to versions @ versions according to the North late Sireo has been canceled.

    It is difficult to say how to do this without any work example. My first estimate is to just add an integer column with the commands you want.

    Once, there will be a simple, brute-force way to add each boxplatform one at a time. Import the NP import ponds as numpy as

     PD import matplotlib.pyplot plt df = pd.DataFrame (np.random.rand (37,4), column = list ('ABCD')) Enables column_my_order = ['C' 'A', 'D', 'B'] fig, ax = plt.subplots (), position for column (columns_my_order): ax.boxplot (df [column], position = [Position]) ax.set_xticks (range (position + 1)) ax.set_xticklabels (columns_my_order) ax.set_xlim (xmin = -0.5) plt.show ()   



Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -