Convert object data type to string issue in python

后端 未结 3 1907
执笔经年
执笔经年 2020-12-02 02:31

How can I convert an object dtype structure to a string dtype? The method below is not working and the column remains object after converting to a string with <

3条回答
  •  独厮守ぢ
    2020-12-02 03:12

    I got it to work using 'string' instead of str

    df['country'] = df['country'].astype('string')
    df.dtypes
    #country    string
    

提交回复
热议问题