python - Pandas :设置编号。最大行数

我在查看以下 DataFrame 时遇到问题:

n = 100
foo = DataFrame(index=range(n))
foo['floats'] = np.random.randn(n)
foo

问题是它不会在 ipython 笔记本中默认打印所有行,但我必须切片才能查看结果行。即使是以下选项也不会改变输出:

pd.set_option('display.max_rows', 500)

有人知道如何显示整个数组吗?

最佳答案

设置display.max_rows:

pd.set_option('display.max_rows', 500)

对于旧版本的 pandas (display.height 和 display.max_rows

pd.set_option('display.height', 500)
pd.set_option('display.max_rows', 500)

另见 pd.describe_option('display') .

您可以像这样暂时为此一次设置一个选项:

from IPython.display import display
with pd.option_context('display.max_rows', 100, 'display.max_columns', 10):
    display(df) #need display to show the dataframe when using with in jupyter
    #some pandas stuff

您还可以像这样将选项重置为其默认值:

pd.reset_option('display.max_rows')

然后将它们全部重置:

pd.reset_option('all')

关于python - Pandas :设置编号。最大行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424493/

相关文章:

javascript - 在jQuery中将逗号添加到数字

java - 生成用空格填充的固定长度字符串

python - 轻松漂亮地打印花车?

Excel CSV - 数字单元格格式

java - Intellij 代码格式化,Java 新行注解

python - 使用标准 json 模块格式化 float

java - netbeans 中的代码清理

html - Bootstrap 3.0 : How to have text and input

string - 如何将 Int 转换为给定长度的字符串,前导零对齐?

c# - 在 C# 中的字符串中找到 {0} 是什么意思?