博客
关于我
彻底解决python打印结果省略号的问题显示宽度
阅读量:432 次
发布时间:2019-03-06

本文共 665 字,大约阅读时间需要 2 分钟。

pandas是python中非常强大的数据分析工具,但在实际操作中,数据框的显示可能会因为列数或行数过多而出现省略号,导致我们无法清晰看到数据的大致分布情况。了解数据的分布范围对于后续的可视化和分析工作至关重要。为了解决这个问题,我们可以通过pandas内置的设置选项来调整显示的数目和宽度。

在pandas中,通过set_option()方法可以灵活配置显示选项。具体来说,主要涉及以下几个参数:display.max_columns、display.max_rows、display.max_colwidth和display.line_width。通过适当调整这些参数的值,我们可以让数据框在显示时能够完整呈现,避免信息被遮挡。

以下是一些常用的设置示例:

import pandas as pd
pd.set_option('display.max_columns', 1000)
pd.set_option('display.width', 1000)
pd.set_option('display.max_colwidth', 1000)

通过以上代码,我们可以将max_columns设置为1000列,这意味着数据框在显示时可以展示更多的列信息。同时,将max_width和max_colwidth也设置为1000,可以让每一列的数据在展示时不受宽度限制,从而避免数据被截断。

这些设置将使pandas在打印数据时能够更全面地展示数据框的内容,有助于我们更好地理解数据的分布情况,为后续的数据可视化和分析打下坚实基础。

转载地址:http://flwyz.baihongyu.com/

你可能感兴趣的文章
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>