pandas - 特别篇(关于读取DataFrame数据显示不完全的解决办法)
今天在做数据处理的时候,发现,pandas.read_csv()
读出来的数据,因为数据量太大,行列之前做了省略处理。
Rank Title ... Revenue (Millions) Metascore
0 1 Guardians of the Galaxy ... 333.13 76.0
1 2 Prometheus ... 126.46 65.0
2 3 Split ... 138.12 62.0
3 4 Sing ... 270.32 59.0
4 5 Suicide Squad ... 325.02 40.0
.. ... ... ... ... ...
995 996 Secret in Their Eyes ... NaN 45.0
996 997 Hostel: Part II ... 17.54 46.0
997 998 Step Up 2: The Streets ... 58.01 50.0
998 999 Search Party ... NaN 22.0
999 1000 Nine Lives ... 19.64 11.0[1000 rows x 12 columns]
就像这样,其中大多数的数据都被省略号
给代替了
那应该怎么解决呢?查阅官方文档之后发现,这个问题可以通过pandas内置的set_option()方法解决,
从上面的属性设置中可以看到,与显示的行数列数有关的选项主要是[display]
中的code[max_columns,max_rows,max_colwidth,line_width]
等这几项,只需要将这几项属性值设置得大一些就可以解决。
具体代码
#导入模块
import pandas as pd#设置中文字体路径
my_font = font_manager.FontProperties(fname="C:\Windows\Fonts\msyh.ttc")#设置显示范围
pd.set_option('display.max_columns', 1000)pd.set_option('display.width', 1000)pd.set_option('display.max_colwidth', 1000)
得到结果
Rank Title Genre Description Director Actors Year Runtime (Minutes) Rating Votes Revenue (Millions) Metascore
0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe. James Gunn Chris Pratt, Vin Diesel, Bradley Cooper, Zoe Saldana 2014 121 8.1 757074 333.13 76.0
1 2 Prometheus Adventure,Mystery,Sci-Fi Following clues to the origin of mankind, a team finds a structure on a distant moon, but they soon realize they are not alone. Ridley Scott Noomi Rapace, Logan Marshall-Green, Michael Fassbender, Charlize Theron 2012 124 7.0 485820 126.46 65.0
2 3 Split Horror,Thriller Three girls are kidnapped by a man with a diagnosed 23 distinct personalities. They must try to escape before the apparent emergence of a frightful new 24th. M. Night Shyamalan James McAvoy, Anya Taylor-Joy, Haley Lu Richardson, Jessica Sula 2016 117 7.3 157606 138.12 62.0
3 4 Sing Animation,Comedy,Family In a city of humanoid animals, a hustling theater impresario's attempt to save his theater with a singing competition becomes grander than he anticipates even as its finalists' find that their lives will never be the same. Christophe Lourdelet Matthew McConaughey,Reese Witherspoon, Seth MacFarlane, Scarlett Johansson 2016 108 7.2 60545 270.32 59.0
4 5 Suicide Squad Action,Adventure,Fantasy A secret government agency recruits some of the most dangerous incarcerated super-villains to form a defensive task force. Their first mission: save the world from the apocalypse. David Ayer Will Smith, Jared Leto, Margot Robbie, Viola Davis 2016 123 6.2 393727 325.02 40.0
.. ... ... ... ... ... ... ... ... ... ... ... ...
995 996 Secret in Their Eyes Crime,Drama,Mystery A tight-knit team of rising investigators, along with their supervisor, is suddenly torn apart when they discover that one of their own teenage daughters has been brutally murdered. Billy Ray Chiwetel Ejiofor, Nicole Kidman, Julia Roberts, Dean Norris 2015 111 6.2 27585 NaN 45.0
996 997 Hostel: Part II Horror Three American college students studying abroad are lured to a Slovakian hostel, and discover the grim reality behind it. Eli Roth Lauren German, Heather Matarazzo, Bijou Phillips, Roger Bart 2007 94 5.5 73152 17.54 46.0
997 998 Step Up 2: The Streets Drama,Music,Romance Romantic sparks occur between two dance students from different backgrounds at the Maryland School of the Arts. Jon M. Chu Robert Hoffman, Briana Evigan, Cassie Ventura, Adam G. Sevani 2008 98 6.2 70699 58.01 50.0
998 999 Search Party Adventure,Comedy A pair of friends embark on a mission to reunite their pal with the woman he was going to marry. Scot Armstrong Adam Pally, T.J. Miller, Thomas Middleditch,Shannon Woodward 2014 93 5.6 4881 NaN 22.0
999 1000 Nine Lives Comedy,Family,Fantasy A stuffy businessman finds himself trapped inside the body of his family's cat. Barry Sonnenfeld Kevin Spacey, Jennifer Garner, Robbie Amell,Cheryl Hines 2016 87 5.3 12435 19.64 11.0[1000 rows x 12 columns]
问题就迎刃而解了~~~
pandas - 特别篇(关于读取DataFrame数据显示不完全的解决办法)相关推荐
- 硬盘分区按照1G=1024M换算分区后不是整数(想分10G,分区时填入大小102400M.但是分区完毕显示却是99.9G或近似值9.XXG,而不是10G整)。本篇为这个问题的原理分析和解决办法
提出问题 老早以前的问题了,今天分区的时候按照近似算法又出现又出现了近似值, 这99.98简直不能忍 硬盘分区按照1G=1024M换算分区后不是整数(想分10G,分区时填入大小102400M.但是分区 ...
- python逐行读取数据时出现错误_Python利用逐行读取readline()打印出现空行的解决办法...
Python Python开发 Python语言 Python利用逐行读取readline()打印出现空行的解决办法 在利用readline()进行逐行读取文件的时候,我们一般使用以下程序: f=op ...
- [salmon_gs]pandas.read_csv() 报错 OSError: Initializing from file failed的解决办法
@[salmon_gs]pandas.read_csv() 报错 OSError: Initializing from file failed的解决办法 错误1 在这里插入代码片 import pan ...
- java页面数值转文本_Java读取Excel表格以及读取数字列转为文本的解决办法
Java读取Excel表格代码和把数字列转为文本的解决办法. 所需 jar 包:dom4j-1.6.1.jar ,poi-3.8-20120326.jar,poi-ooxml-3.8-20120326 ...
- Java读取Excel表格以及读取数字列转为文本的解决办法
Java读取Excel表格代码和把数字列转为文本的解决办法. 所需 jar 包:dom4j-1.6.1.jar ,poi-3.8-20120326.jar,poi-ooxml-3.8-20120326 ...
- pandas 之 to_csv 保存数据出现中文乱码问题及解决办法
1. 使用scrapy框架爬取了一些汽车评价保存在csv文件中,但是直接打开时乱码了. 2. 使用pandas读取再使用to_csv()方法重新保存 import pandas as pdfile_ ...
- Python 技术篇-使用opencv库读取中文路径图片报错解决办法
我们需要安装和使用 numpy 库,直接 pip install numpy 就好了. 用 numpy 读取处理图片,再对 numpy 处理后的图片数据进行转码,转化为图片对象. #!/user/bi ...
- Java中读取本地图片并转为base64解决办法
/** * imgFile 图片本地存储路径 */ public static String getImgFileToBase64(String imgFile) {//将图片文件转化为字节数组字符串 ...
- linux调用odbc接口乱码,linux中pypyodbc读取GB编码mdb中文乱码解决办法
当前1.3.3版本的pypyodbc在linux系统上面已经可以读取有中文字符的mdb文件,不再出现异常,但是读取的中文字符却全是乱码. 下面是根据一些现象的合理推论: mdb文件来自于windows ...
最新文章
- npoi上传xlsx文件,并读取数据
- compareto方法_compare方法和compareTo方法区别
- linux应用程序开发数据,《嵌入式linux应用程序开发详解》核心笔记
- 华为手机在开发Android调试时logcat不显示输出信息的解决办法
- 解决pycharm安装包过程出现的问题:module 'pip' has no attribute 'main'
- 2014 计算机网络 考研真题,2014计算机网络考研试题过关必练
- SCU 4439 Vertex Cover(二分图最小覆盖点)题解
- 消息队列——发布订阅模式
- spring@Autowired的对象为null,非容器中的类如何调用容器中的类
- 网易云音乐上市首日收跌2.49% 盈利困境仍待解
- JBoss3.0 下配置和部署EJB简介
- 浅谈UDP(数据包长度,收包能力,丢包及进程结构选择)
- 魏武帝 太祖知不可匡正,遂不复献言
- web逻辑思维题目_学编程必看:10道逻辑思维测试题(附答案)
- 一种可调电子负载电路/可调恒流源电路
- 电脑屏幕怎么截取,常见的几种电脑截屏方法
- 2022年10月最新CPU天梯图 CPU天梯图高清完整版
- 加速度计和陀螺仪设备
- 关于一个《十六进制转十进制》的小程序
- 计算机多任务处理未来的挑战,基于多任务学习的多姿态人脸重建与识别Multi-poseface-计算机应用.PDF...