简体   繁体   English

Python:将列从float转换为int

[英]Python: Convert column from float to int

I am using a pandas, and need to concat two dataframes based on a set_id index. 我正在使用熊猫,并且需要基于set_id索引连接两个数据帧。 One of the dataframes has these as floats (see below). 数据框之一具有浮点数(请参见下文)。 How can I convert these to ints? 如何将它们转换为整数?

在此处输入图片说明

你可以这样做

df.index = df.index.astype(int)

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

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