2019-01-16
阅读量:
722
如何将pandas对象转换为指定的dtype(2)
由于数据有一些“nan”值,为了避免任何错误,我们将删除包含任何nan
值的所有行。
# drop all those rows which
# have any 'nan' vlaue in it.
df.dropna(inplace = True)
# let's find out the data type of Weight column
before = type(df.Weight[0])
# Now we will convert it into 'int64' type.
df.Weight = df.We<strong>ight.astype('int64')
# let's find out the data type after casting
after = type(df.Weight[0])
# print the value of before
before
# print the value of after
after






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论