Python Forum
Separating Names & Counting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Separating Names & Counting
#1
Hi,
I'm doing a Uni course & I'm a bit stuck & would appreciate some help please.

I have a column in a data frame that contains data as per below (no spacing)
ATTENDEES
John,Jan,Paul
Kylie,Paul,Scott,Jason
Jan,Scott,John

I' trying to seperate the data so I can show who is attending in a list like
ATTENDEES
John
Jan
Paul
Kylie
Scott
Jason

Then be able to count how many are attending
ATTENDEES
John 1
Jan 2
Paul 2
Kylie 1
Scott 2
Jason 1

I've tried splitting the names using
names=masterlist['attendees'].str.split(pat = ',', expand = True)

and counting by using
CountNames=names.groupby(0).count()

but it does not include all the data only the 1st new column from the split
and counting is across all columns.

Thanks in advance
Steve
Reply


Messages In This Thread
Separating Names & Counting - by Steven5055 - Nov-03-2022, 06:00 AM
RE: Separating Names & Counting - by Larz60+ - Nov-03-2022, 07:32 AM
RE: Separating Names & Counting - by Steven5055 - Nov-03-2022, 08:20 AM
RE: Separating Names & Counting - by DeaD_EyE - Nov-03-2022, 10:08 AM
RE: Separating Names & Counting - by Steven5055 - Nov-04-2022, 04:36 AM
RE: Separating Names & Counting - by deanhystad - Nov-04-2022, 10:08 AM
RE: Separating Names & Counting - by Steven5055 - Nov-06-2022, 12:04 AM
RE: Separating Names & Counting - by deanhystad - Nov-06-2022, 12:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020