将int值更改为.00格式 [英] Change int value to .00 format

查看:69
本文介绍了将int值更改为.00格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据框-

   year  month             type   amount
0  2019  9          Not Applicable    8000.00       
1  2019  10         Not Applicable    7500.00       
2  2019  11         Goods & Services  14000.35      
3  2019  11         Not Applicable    7500.00       
4  2019  12         Goods & Services  10499.00      
5  2019  12         Not Applicable    9801.00   

我的列数已满,但我想转换另一个此格式的列月份-

I have column amount fully round of but I want to convert another column month to this format like this -

   year  month             type   amount
0  2019  9.00          Not Applicable    8000.00       
1  2019  10.00         Not Applicable    7500.00       
2  2019  11.00         Goods & Services  14000.35      
3  2019  11.00         Not Applicable    7500.00       
4  2019  12.00         Goods & Services  10499.00      
5  2019  12.00         Not Applicable    9801.00   

我如何实现这一目标。

推荐答案

df.month = df.month.astype(float)

df['month'] = df['month'].astype(float)

这篇关于将int值更改为.00格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆