Pandas Series of lists to one series

后端 未结 9 2224
野性不改
野性不改 2020-12-28 13:18

I have a Pandas Series of lists of strings:

0                           [slim, waist, man]
1                                [slim, waistline]
2                       


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 13:34

    You are basically just trying to flatten a nested list here.

    You should just be able to iterate over the elements of the series:

    slist =[]
    for x in series:
        slist.extend(x)
    

    or a slicker (but harder to understand) list comprehension:

    slist = [st for row in s for st in row]
    

提交回复
热议问题