0

So, I have a data frame in pandas which contains a column called "Tracking". Now the column contains different values like "Received", "In Progress", "Delayed due to something" etc. I am wondering is there a possibility that i can get the sum of each of these status from this column. so for example

Input

df = pd.DataFrame({'Tracking': ['Received', 'Received', 'In Progress', 'Delayed due to something'], 'col2':...})

Output:

Received : 2
In Progress: 1
Delayed due to something :1

I know this question might have been asked previously if there is a answer please provide a link if not any help is appreciated thank you.

Nick
  • 138,499
  • 22
  • 57
  • 95

1 Answers1

0

You can use value_counts

df = pd.DataFrame({'Tracking': ['Received', 'Received', 'In Progress', 'Delayed due to something','In Progress','In Progress']})

print(df.Tracking.value_counts())
In Progress                 3
Received                    2
Delayed due to something    1
Name: Tracking, dtype: int64
taipei
  • 1,010
  • 10
  • 20