繁体   English   中英

在 pandas.to_numeric() 中将 int64 转换为 int32

[英]convert int64 to int32 in pandas.to_numeric()

我有一个带有dtype(int64)列的数据框,我想将其转换为int32
当我在下面运行代码时,我得到dtype(int8)类型但我想得到int32

pd.to_numeric(x, downcast="integer")

我该怎么做!

尝试这个,

df['col'].astype(np.int32)

astype 文档链接: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.astype.html

请查看 numpy 数据类型文档: https://numpy.org/doc/stable/user/basics.types.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM