Home > Enterprise >  How can I make countplot of multiple label with multiple column
How can I make countplot of multiple label with multiple column

Time:11-13

Given data like down below

test = pd.DataFrame(np.array([
    ["Yes", "No", "No", "Yes", "Maybe"],
    ["Yes", "Yes", "Yes", "Maybe", "Maybe"],
    ["Maybe", "Yes", "Yes", "No", "No"],
    ["No", "Yes", "Maybe", "No", "No"],
    ["Maybe", "Maybe", "Maybe", "No", "Yes"],
    ])
    ,columns=['a','b','c','d', 'e'])

I want something that looks like image down below.

enter image description here

So column a would have bar graph that has three bar each indicating count of 2 "Yes", 1 "No", 2 "Maybe". And so does the columns remaining.

I tried making new dataframe temp = df.apply(pd.Series.value_counts) and with sns.countplot() but It resulted just 5 bar instead of 3*5 bar.

Please help me to make bar graph that has multilabel from multiple column.

Thank you for reading.

CodePudding user response:

Use melt_countplot

  • Related