Change column type in pandas

前端 未结 9 1341
萌比男神i
萌比男神i 2020-11-21 04:15

I want to convert a table, represented as a list of lists, into a Pandas DataFrame. As an extremely simplified example:

a = [[\'a\', \'1.2\', \'         


        
9条回答
  •  既然无缘
    2020-11-21 05:15

    this below code will change datatype of column.

    df[['col.name1', 'col.name2'...]] = df[['col.name1', 'col.name2'..]].astype('data_type')
    

    in place of data type you can give your datatype .what do you want like str,float,int etc.

提交回复
热议问题