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

标签 python pandas dataframe

删除 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

关于python - 如何删除 Pandas DataFrame 中的小数点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52673814/

相关文章:

python - 为什么 wx.Yield() 不起作用?

python - "Process finished with exit code 1"是什么意思?

python - Pandas:检查 json 对象中是否存在 dataframe 列

python - 地理错误: GeocoderServiceError: HTTP Error 500: Internal Server Error using pandas apply function with str concat

python - 计算最高分 - Pandas 中每个供应商的最低分

python - 对于其他列中的每次更改,我们如何用这些行的平均值替换多行数据?

python - 人口平衡分层随机抽样

Python:带颜色条的条形图

python - 比较 Pandas 中的两个数据帧,以获得大于另一个的所有值

python - 如何选择要在 pandas groupby 中显示的列值