zjrc,杜存刚,香港金道贵金属有限公司
控制台打印时显示的2位小数:
pd.set_option('precision', 2)
实际修改数据精度:
官例:
>>> df = pd.dataframe(np.random.random([3, 3]), ... columns=['a', 'b', 'c'], index=['first', 'second', 'third']) >>> df a b c first 0.028208 0.992815 0.173891 second 0.038683 0.645646 0.577595 third 0.877076 0.149370 0.491027 >>> df.round(2) a b c first 0.03 0.99 0.17 second 0.04 0.65 0.58 third 0.88 0.15 0.49 >>> df.round({'a': 1, 'c': 2}) a b c first 0.0 0.992815 0.17 second 0.0 0.645646 0.58 third 0.9 0.149370 0.49 >>> decimals = pd.series([1, 0, 2], index=['a', 'b', 'c']) >>> df.round(decimals) a b c first 0.0 1 0.17 second 0.0 1 0.58 third 0.9 0 0.49
以上这篇pandas 小数位数 精度的处理方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python爬虫:Request Payload和Form Data的简单区别说明
浅谈Python中threading join和setDaemon用法及区别说明
Python3-异步进程回调函数(callback())介绍
python继承threading.Thread实现有返回值的子类实例
Python中使用threading.Event协调线程的运行详解
网友评论