+2 votes
in Python by
From this covid-19 dataset:

How can you make a bar-plot for the top-5 states with the most amount of deaths?

1 Answer

0 votes
by

max_death_cases=today.sort_values(by=”deaths”,ascending=False)

max_death_cases

sns.set(rc={‘figure.figsize’:(15,10)})

sns.barplot(x=”state”,y=”deaths”,data=top_states_death,hue=”state”)

plt.show()

Code Explanation:

We start off by sorting our dataframe in descending order w.r.t the “deaths” column:

max_death_cases=today.sort_values(by=”deaths”,ascending=False)

Max_death_cases

Then, we go ahead and make the bar-plot with the help of seaborn library:

sns.set(rc={‘figure.figsize’:(15,10)})

sns.barplot(x=”state”,y=”deaths”,data=top_states_death,hue=”state”)

plt.show()

Here, we are mapping “state” column onto the x-axis and “deaths” column onto the y-axis.

Related questions

+1 vote
asked Feb 15, 2021 in Python by SakshiSharma
0 votes
asked Jan 1, 2021 in Python by SakshiSharma
...