How to get percentage of different shipment mode in pandas?

Question:

How can I get percent off different Ship Mode?

df3.groupby('Ship Mode')['Ship Mode'].count()

My o/p
My database

Asked By: Arijit Koley

||

Answers:

df3.groupby('Ship Mode')['Ship Mode'].count() / len(df3)
Answered By: 11574713

Try this,

df3['Ship Mode'].value_counts(normalize=True)

Use Value counts and pass normalization.

Value Counts: https://pandas.pydata.org/docs/reference/api/pandas.Series.value_counts.html

Answered By: Mohamed Thasin ah
df3.groupby('Ship Mode')['Ship Mode'].count()/df3.shape[0]
Answered By: Abhishek
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.