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 .astype
import pandas as pd
df = pd.DataFrame({'country': ['A', 'B', 'C', 'D', 'E']})
df.dtypes
#country object
#dtype: object
df['county'] = df['country'].astype(str)
df.dtypes
#country object
#dtype: object
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…