python dataframe 输出结果整行显示的方法

yipeiwu_com6年前Python基础

在使用dataframe时遇到datafram在列太多的情况下总是自动换行显示的情况,导致数据阅读困难,效果如下:

# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.randn(1, 20))
print df

显示效果:

   0   1   2   3   4   5   6 \
0 -1.193428 -0.870381 -0.970323 -1.062275 1.227282 -3.016298 -0.587623 

   7   8   9   10  11  12  13 \
0 -0.608017 -0.006382 0.275454 -0.073537 1.217392 -0.12844 -1.228424 

   14  15  16  17  18  19 
0 -1.153452 0.191372 0.582537 0.503437 -2.263716 -0.529881 
height has been deprecated.

解决方法:

在代码中设置显示的长宽等,如下代码示例:

# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd

pd.set_option('display.height',1000)
pd.set_option('display.max_rows',500)
pd.set_option('display.max_columns',500)
pd.set_option('display.width',1000)

df = pd.DataFrame(np.random.randn(1, 20))
print df

以上这篇python dataframe 输出结果整行显示的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python类的基础入门知识

复制代码 代码如下:class Account(object): "一个简单的类" account_type="Basic" def __init__(self,name,balance...

python常见数制转换实例分析

本文实例讲述了python常见数制转换用法。分享给大家供大家参考。具体分析如下: 1.进位制度 Python中二进制是以0b开头的: 例如: 0b11 则表示十进制的3 8进制是以0开头...

python实现本地图片转存并重命名的示例代码

//有1-22个文件夹,各文件夹下有Detect_0文件夹,此文件夹下有source与mask文件夹,目的是将需要获取图片的 文件夹下的图片复制到新的文件夹下并按顺序重命名 impo...

pytorch索引查找 index_select的例子

index_select anchor_w = self.FloatTensor(self.scaled_anchors).index_select(1, self.LongTensor...

python list排序的两种方法及实例讲解

对List进行排序,Python提供了两个方法 方法1.用List的内建函数list.sort进行排序 list.sort(func=None, key=None, reverse=Fa...