Python Pandas - Changing some column types to categories

前端 未结 7 1306
孤独总比滥情好
孤独总比滥情好 2021-01-30 01:08

I have fed the following CSV file into iPython Notebook:

public = pd.read_csv(\"categories.csv\")
public

I\'ve also imported pandas as pd, nump

7条回答
  •  悲哀的现实
    2021-01-30 01:30

    I found that using a for loop works well.

    for col in ['col_variable_name_1', 'col_variable_name_2', ect..]:
        dataframe_name[col] = dataframe_name[col].astype(float)
    

提交回复
热议问题