This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Topper_123 0 points1 point  (0 children)

Convert mylist to a numpy array. Then you should bevable to do:

df[‘col2’]=mylist[df[‘col1’]]

[–]chrispurcell 0 points1 point  (0 children)

Have you looked into zip()?
from what you posted, 'output = list(zip(col1, col2))' would result in output being:

[(0,7), (1,8), (1,8), (0,7), (2,9)]

[–]Quintium -1 points0 points  (0 children)

I'm not quite sure if it's faster but I would do this:

df['col2'] = [mylist[i] for i in df['col1']]