【发布时间】:2020-12-21 21:52:35
【问题描述】:
我的熊猫 df:
first second third fourth fifth
0 x y 12 2 0
1 a b 1 1 1
2 c d 2 12 0
要检查列数据类型,我使用:
df.info()
结果是:
<class 'pandas.core.frame.DataFrame'>
first 380 non-null object
second 380 non-null object
third 380 non-null object
fourth 380 non-null object
fifth 380 non-null int32
我想将第一列和第二列转换成字符串:
df['first'] = df['first'].astype(str)
df['second'] = df['second'].astype(str)
我想检查一下:
df.info()
first 380 non-null object
second 380 non-null object
third 380 non-null object
fourth 380 non-null object
fifth 380 non-null int32
所以它不起作用,我在哪里做错了?
【问题讨论】: