[英]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:
You could use either of the following methods:您可以使用以下任一方法:
Method-1 :方法一:
pd.options.display.max_columns = None
Method-2 :方法2 :
pd.set_option('display.max_columns', None)
# to reset this
pd.reset_option('display.max_columns')
Method-3 :方法3 :
# 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 :
# assuming df is your dataframe
pd.set_option('max_columns', df.columns.size)
# to reset this
pd.reset_option('max_columns')
pd.set_option('display.expand_frame_repr', False)
I will recommend you to explore the following resources for more details and examples.我建议您浏览以下资源以获取更多详细信息和示例。
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.