0

I have a data frame where there are 5 columns that have comments on different topics. I want to plot the count of all such columns by a target variable team so that I can have a all the plots available at once.

The dataframe looks like this :

Function             Accountability   Reward    Pay    Others
Services             Abc               Abc      Abc    Abc
Manufacturing .      NA                NA       NA     NA
Digital Technology   DEF               DEF      DEF   DEF
Services             Abc               Abc      Abc    Abc
Manufacturing .      NA                NA       NA     NA
Digital Technology   DEF               DEF      DEF   DEF

Now there are 2 comments for Services under accountability and so on. So,I want to create multiple plots in one code that shows the count of all the comments by Function. I DO NOT want to have one bar chart that shows everything. I want different bar charts that shows count of each comment column by function separately.

0

1 Answer 1

2

Is this what you are looking for ?

import pandas as pd 
import matplotlib.pyplot as plt 
plt.rcParams['figure.figsize'] = (15,5)

# Your table has been read to 'df' 

df1 = df.drop('Function', axis=1)

plt.subplot(1,3,1)
df1[df.Function == 'Services'].count().plot.bar()
plt.title('Services')

plt.subplot(1,3,2)
df1[df.Function == 'Digital Technology'].count().plot.bar()
plt.title('Digital')

plt.subplot(1,3,3)
df1[df.Function == 'Manufacturing.'].count().plot.bar()
plt.title('Manufacturing')

Plot

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! Yes, this is what I wanted.! Super!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.