将函数应用于包含列表的熊猫数据框列

时间:2018-11-26 12:51:02

标签: python pandas dataframe

我有一个pandas数据框,其中一列包含网址列表。我正在尝试清洁并删除“ ...”

我大约有465万条记录,并且希望尽可能高效地执行此功能。

输入:

1                                         []
2                                         []
3                          ['http://t.co…/']
4                          ['https://t.co/']
5                          ['http://t.co/…']
6                          ['http://t.co/…']
7              ['http://t.co/', 'http://t…']
8                   ['http://facebook.com/']

Name: urls, Length: 100, dtype: object

输出:

 1                                         []
 2                                         []
 3                          ['http://t.co/']
 4                          ['https://t.co/']
 5                          ['http://t.co/']
 6                          ['http://t.co/']
 7              ['http://t.co/', 'http://t']
 8                   ['http://facebook.com/']

Name: urls, Length: 100, dtype: object

1 个答案:

答案 0 :(得分:0)

Data1 ['urls'] = Data1 ['urls']。apply(lambda行:[i.replace('…','')for i in row))

相关问题