I have a pandas dataframe where I'm trying to add a new column that repeats the number in the score column as many times as there are words in the words column (which contains tuples of words). I have something like this:
In [7]: df
Out[7]:
titles score
0 [cat, father, bakery] 43
1 [brick, swordsmith, park, apple] 68
And I want something like this:
In [8]: df
Out[8]:
titles score score_repeat
0 [cat, father, bakery] 43 [43, 43, 43]
1 [brick, swordsmith, park, apple] 68 [68, 68, 68, 68]
I am not very experienced but I have tried something like:
df['score_repeat'] = len(df['titles'])*df['score']
But that just gives me a column where the score is multiplied by the length of the column.
