Issue
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.
Solution
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
Answered By - taipei
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.