Error while visualizing data with countplot?

Question:

enter image description here

Since there is a categorical data in the picture here, it wants me to convert it, but I want to make the categorical data count

i need to plot countplot of how many should be from which country but i get valuerror error

Asked By: nisa kıraç

||

Answers:

You can use value_counts method:

from matplotlib import pyplot as plt

# get count of categorical values
counts = df2021['Regional indicator'].value_counts()

# make a bar plot (you can use some other plot, too)
plt.bar(counts.index, counts)

# make your xticks clearly visible (you can try different angles)
plt.xticks(rotation=90)

plt.show()
Answered By: rajkumar_data
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.