pandas convert strings to float for multiple columns in dataframe

后端 未结 3 1464
灰色年华
灰色年华 2021-01-02 02:30

I\'m new to pandas and trying to figure out how to convert multiple columns which are formatted as strings to float64\'s. Currently I\'m doing the below, but it seems like

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 02:50

    answering a comment in the accepted answer: for specific columns make sure you don't do it inplace.

    df['Column1'] = df['Column1'].replace('%','',regex=True).astype('float')/100
    

提交回复
热议问题