Python Forum
Separating Names & Counting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Separating Names & Counting
#8
I was thinking of using str.join().
import pandas as pd
df = pd.read_csv("party.csv")
names = ",".join(df["ATTENDEES"]).split(",")
print(names)
Output:
['John', 'Jan', 'Paul', 'Kylie', 'Paul', 'Scott', 'Jason', 'Jan', 'Scott', 'John']
Quote:Also is there anyway of listing the names up/down rather than left/right.
Of course, but you'll need to control the printing yourself instead of using the default str representation of a list.

You could use join().
print("\n".join(names))
Output:
John Jan Paul Kylie Paul Scott Jason Jan Scott John
Or you could print a name at a time in a for loop.
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