0

I have a dataframe with multiple columns such as product name, reviews, origin, and etc. Here, I want to create a barplot with only the data from "Origin" column.

To do this, I used the code: origin = df['Origin'].value_counts()

With this, I was able to get a list of countries with corresponding frequencies (or counts). Now, I want to create a boxplot with each country on X-axis and counted frequencies on the Y-axis. Although the column for frequencies have a column label, I am unable to set the X-axis as the countries are merely saved as index. Would there be a better way to count the column "Origin" and make it into a barplot?

Thanks in advance.

mufassir
  • 406
  • 5
  • 16
  • 1
    Did you mean a `barplot`? You can't compute a `boxplot` on already aggregated data. Try `df['Origin'].value_counts().plot.bar()` – mozway Nov 22 '22 at 05:32
  • @mozway oops I mean barplot. Thanks for pointing it out! – python noobie Nov 22 '22 at 05:52
  • Does this answer your question? [Use index in pandas to plot data](https://stackoverflow.com/questions/20084487/use-index-in-pandas-to-plot-data) – Frodnar Nov 22 '22 at 12:16

0 Answers0