Reputation: 87
I have a column with text which is stored as a object tpye in a pandas dataframe. The following two codes to not work. The required column is still object type.
TD_Eco_Comb_c['CountryPair'] = TD_Eco_Comb_c['CountryPair'].astype('|S')
TD_Eco_Comb_c['CountryPair'] = TD_Eco_Comb_c['CountryPair'].astype('str')
Any advice?
Upvotes: 0
Views: 45
Reputation: 10090
A string is always going to have dtype == 'object'
in a dataframe.
This comes from numpy, which uses purely numerical dtypes. Everything that isn't numerical is classified as an 'object'. Your data is already in the format you need it to be in.
Upvotes: 1