Suganesh Kumar
Suganesh Kumar

Reputation: 167

Get Unique value from Series of elements in a column

How to get value counts for below given data in a column

Ticket_No - COLUMN NAME

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

Answers (1)

Andy L.
Andy L.

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

Related Questions