How can I convert columns of a pandas DataFrame into a list of lists?

前端 未结 2 1016

I have a pandas DataFrame with multiple columns.

2u    2s    4r     4n     4m   7h   7v
0     1     1      0      0     0    1
0     1     0      1      0            


        
2条回答
  •  离开以前
    2020-12-13 02:33

    To change Dataframe into list use tolist() function to convert Let use say i have Dataframe df

    to change into list you can simply use tolist() function

    df.values.tolist()
    

    You can also change a particular column in to list by using

    df['column name'].values.tolist()
    

提交回复
热议问题