How to assign a list to existing column of Pandas Data Frame?

后端 未结 2 988
孤街浪徒
孤街浪徒 2021-02-14 02:24

I apply some functions and generate a new column values to a existing column of Pandas dataframe. However df[\'col1\'] = new_list does not work to assign new list t

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 02:43

    I think this question is looking for something like this.

    new_list = [1,2,3]
    
        col1
    0  [1,2,3]
    1  [1,2,3]
    2  [1,2,3]
    

    And I think I found the answer here:

    how to assign an entire list to each row of a pandas dataframe

提交回复
热议问题