My dataset contains a column with names that I want to check in a for loop:
Name Age
John 32
Luke 23
Christine 54
Mary 39
AnneMarie 42
Eoin 23
I would need to check them via a website which generates a pair ('name', score), where score is a number.
This pair comes from the following code (it cannot work as it was extracted only for showing how I have got data that I would like in my dataframe)
for name in df['Name']:
# missing code
for c in zip(names, scores):
print(c)
For example, when name = John
, c
gives me the following output:
('Julie', 6.7)
('Michael', 3.4)
('John John', 3.1)
('Ludo', 3.0)
('Chris', 3.0)
when name = Luke
, c
gives me the following output:
('Mary', 2.7)
('Michael', 2.1)
('Bill', 3.5)
('Jess', 3.2)
and so on.
I would like to add this information in my dataframe in order to have something like this:
Name Age Friends Score
John 32 [Julie, Michael, John John, Ludo, Chris] [6.7, 3.4, 3.1, 3.0, 3.0]
Luke 23 [Mary, Michael, Bill, Jess] [2.7,2.1, 3.5, 3.2]
Christine 54
Mary 39
AnneMarie 42 ....
Eoin 23
I would appreciate your help on this, on how I can get a similar dataframe by using the results c for each name in the Name
column.