简体   繁体   English

Python Spyder:在“.describe()”中显示熊猫数据框的所有列

[英]Python Spyder: Show all colums of a pandas-dataframe in ".describe()"

I am stuck here, but I it's a two part question.我被困在这里,但这是一个由两部分组成的问题。 Looking at the output of.describe(include = 'all'), not all columns are showing;查看 output of.describe(include = 'all'),并非所有列都显示; how do I get all columns to show?如何显示所有列?

This is a common problem that I have all of the time with Spyder, how to have all columns to show in Console.这是我在使用 Spyder 时一直遇到的一个常见问题,如何让所有列都显示在控制台中。 Any help is appreciated.任何帮助表示赞赏。

import matplotlib.pyplot as plt
import pandas as pd
import scipy.stats as stats
import seaborn as sns

mydata = pd.read_csv("E:\ho11.csv")
mydata.head()
print(mydata.describe(include="all", exclude = None))

mydata.info()

OUTPUT: OUTPUT:

Solution解决方案

You could use either of the following methods:您可以使用以下任一方法:

Method-1 :方法一

source 来源

pd.options.display.max_columns = None

Method-2 :方法2

source 来源

pd.set_option('display.max_columns', None)

# to reset this
pd.reset_option('display.max_columns')

Method-3 :方法3

source 来源

# assuming df is your dataframe
pd.set_option('display.max_columns', df.columns.size)

# to reset this
pd.reset_option('display.max_columns')

Method-4 :方法4

source 来源

# assuming df is your dataframe
pd.set_option('max_columns', df.columns.size)

# to reset this
pd.reset_option('max_columns')

To not wrap the output into multiple lines do this要不将输出包装成多行,请执行此操作

source 来源

pd.set_option('display.expand_frame_repr', False)

References参考

I will recommend you to explore the following resources for more details and examples.我建议您浏览以下资源以获取更多详细信息和示例。

  1. How to show all of columns name on pandas dataframe? 如何在熊猫数据框上显示所有列名?

  2. How do I expand the output display to see more columns of a pandas DataFrame? 如何展开输出显示以查看 Pandas DataFrame 的更多列?

  3. How to show all columns / rows of a Pandas Dataframe? 如何显示 Pandas Dataframe 的所有列/行?

Since you are using Spyder the easiest thing to do would be:由于您使用的是 Spyder,因此最简单的方法是:

myview = mydata.describe()

Then you can inspect 'myview' in the variable explorer.然后您可以在变量资源管理器中检查“myview”。

Using pd.set_option listed column names in the console truncated in the middle with three dots.使用 pd.set_option 在控制台中列出的列名称在中间被三个点截断。

To print a full list of the column names from a dataframe to the console in Spyder:要将列名的完整列表从 dataframe 打印到 Spyder 的控制台:

list(df.columns)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM