TypeError: string indices must be integers using pandas apply with lambda

前端 未结 2 1695
旧巷少年郎
旧巷少年郎 2021-01-13 23:55

I have a dataframe, one column is a URL, the other is a name. I\'m simply trying to add a third column that takes the URL, and creates an HTML link.

The column

2条回答
  •  深忆病人
    2021-01-14 00:22

    With zip and string old school string format

    df['sourceURL'] = ['%s.' % (x,y) for x , y in zip (df['url'], df['source'])]
    

    This is f-string

    [f'{y}' for x , y in zip ((df['url'], df['source'])]
    

提交回复
热议问题