python3取消科学计数法_python3使用numpypandas时如何取消科学计数法显示完整输出无省略号...

?博客1031用python进行数据分析时,查看数据,经常发生数据被自动显示成科学记数法的模式,或者多行多列数据只显示前后几行几列,中间都是省略号的情形。

汇总了下解决办法,记录:

环境如下:

python version == 3.6

numpy version == 1.11.3

pandas version == 0.19.2

numpy[pre]import numpy as npnp.set_printoptions(suppress=True, threshold=np.nan)[/pre]suppress=True 取消科学记数法

threshold=np.nan 完整输出(没有省略号)

pandas[pre]import pandas as pdpd.set_option('display.max_columns', 10000, 'display.max_rows', 10000)[/pre]display.max_columns 显示最大列数

display.max_rows 显示最大行数

顺便记下文档里这两个函数的参数:

np.set_printoptionsnp.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, formatter=None)

参数:

precision 设置浮点数的精度  (默认值:8)

threshold 设置显示的数目(超出部分省略号显示, np.nan是完全输出,默认值:1000)

edgeitems 设置显示前几个,后几个 (默认值:3)

suppress 设置是否科学记数法显示 (默认值:False)

示例如下:

[pre]import numpy as npnp.set_printoptions(precision=4, threshold=8, edgeitems=4, linewidth=75, suppress=True, nanstr='nan', infstr='inf')print("precision=4, 浮点数精确小数点后4位: ", np.array([1.23446789]))print("threshold=8, edgeitems=4, 显示8个,前4后4: ", np.arange(10))np.set_printoptions(formatter={'all': lambda x :'int:'+str(-x)})print("formatter, 格式化输出: ", np.arange(5))[/pre]输出如下:

注意:precision自动四舍五入

详细介绍文档: np.set_printoptions

pd.set_optionpd.set_option(pat, value)

参数:

display.[max_categories, max_columns, max_colwidth, max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage, multi_sparse, notebook_repr_html, pprint_nest_depth, precision, show_dimensions]

详细介绍文档:pd.set_option

推荐版块:

稠州社区

天津网络推广

推荐阅读:

活了20多年才知道原来创可贴一直都贴错了这才是正确的使用方法

凌晨2点160余人被抓赣州700多名执法人员出动现场震撼

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值