Assign pandas dataframe column dtypes

后端 未结 6 693
醉梦人生
醉梦人生 2020-12-02 06:03

I want to set the dtypes of multiple columns in pd.Dataframe (I have a file that I\'ve had to manually parse into a list of lists, as the file was

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 06:44

    For those coming from Google (etc.) such as myself:

    convert_objects has been deprecated since 0.17 - if you use it, you get a warning like this one:

    FutureWarning: convert_objects is deprecated.  Use the data-type specific converters 
    pd.to_datetime, pd.to_timedelta and pd.to_numeric.
    

    You should do something like the following:

    • df =df.astype(np.float)
    • df["A"] =pd.to_numeric(df["A"])

提交回复
热议问题