Home > Back-end >  How to get percentage of different shipment mode in pandas?
How to get percentage of different shipment mode in pandas?

Time:08-05

How can I get percent off different Ship Mode?

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

My o/p My database

CodePudding user response:

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

CodePudding user response:

df3.groupby('Ship Mode')['Ship Mode'].count()/df3.shape[0]

CodePudding user response:

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

  • Related