Python Forum
Separating Names & Counting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Separating Names & Counting
#5
OK, so on further reading I've found this post.

how often does a word occur in this column?
https://python-forum.io/thread-10857.htm...ght=genres

If I copy & paste my data into python as per the example it works, but when I try & read it from the CSV file it does not work.

import pandas as pd
import os
party = pd.read_csv('party.csv')
data = party['ATTENDEES']
data_list = data.replace('\n', ',')
data_list = data_list.strip().split(',')
print(Counter(data_list).most_common(15))
Could someone please explain why when I use this it works
data = 'John,Jan,Paul,Kylie,Paul,Scott,Jason,Jan,Scott,John'
BUT
party = pd.read_csv('party.csv')
data = party['ATTENDEES']
Does not work
I'd assume it has something to do with multiple rows or not adding a comma after each row..
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