Hi everyone,
I’m working on data having two columns (one categorical (type), one numerical(amount)). If I want to make a plot showing the fraction of each category and the mean value of numerical variable corresponding to each category, how can I do it?
Which plot to be used?
I thought of a pie chart. But I’m not sure how I can include mean of amount column corresponding to each category .
Hi @ritesh_vesalapu
df[categorical_col].value_couts() / len(df)
- will help you get fractions of categorical columns
df.groupby(categorical_col).mean()
- will help you get mean amount for each category.
You can use a bar plot to visualize both together.
Hi @ritesh_vesalapu
You can draw boxplot per each category to gain even more insights.
Refer to the documentation here https://seaborn.pydata.org/generated/seaborn.boxplot.html, the chart I am talking about is the second one.
2 Likes