Skip to main content
 首页 » 编程设计

python之如何删除 Pandas DataFrame 中的小数点

2025年05月04日20落叶

删除 pandas 数据框中小数的最佳方法是什么?

示例数据:

1.10 
2.20 
3.30 
4.40 

预期结果:

110 
220 
330 
440 

请您参考如下方法:

您可以尝试使用 as df['col'] = (df['col']*100).astype(int) 如下:

df = pd.DataFrame({'col': [1.10, 2.20, 3.30, 4.40]}) 
df['col'] = (df['col']*100).astype(int) 
print(df) 

输出:

   col 
0  110 
1  220 
2  330 
3  440