Reputation: 167
How to get value counts for below given data in a column
ABC10
ABC20
ABC30
XYZ11
XYZ12
IJK11
IJK22
I need count of total ABC,XYZ,IJK
for example, ABC 3, XYZ 2, IJK 2
data.groupby('Ticket_No').size()
Upvotes: 1
Views: 29
Reputation: 25249
Try this
df.Ticket_No.str.findall('^[A-Za-z_]+').str[0].value_counts()
Out[513]:
ABC 3
XYZ 2
IJK 2
Name: Ticket_No, dtype: int64
Upvotes: 1