Pandas: Setting no. of max rows( pandas :设置编号.最大行数)
问题描述
我在查看以下 DataFrame 时遇到问题:
I have a problem viewing the following DataFrame:
n = 100
foo = DataFrame(index=range(n))
foo['floats'] = np.random.randn(n)
foo
问题是它不会在 ipython 笔记本中默认打印所有行,但我必须切片才能查看结果行.即使是以下选项也不会改变输出:
The problem is that it does not print all rows per default in ipython notebook, but I have to slice to view the resulting rows. Even the following option does not change the output:
pd.set_option('display.max_rows', 500)
有人知道如何显示整个数组吗?
Does anyone know how to display the whole array?
推荐答案
设置display.max_rows:
pd.set_option('display.max_rows', 500)
对于旧版本的 pandas (<=0.11.0),您需要同时更改 display.height 和 display.max_rows.
For older versions of pandas (<=0.11.0) you need to change both display.height and display.max_rows.
pd.set_option('display.height', 500)
pd.set_option('display.max_rows', 500)
另见 pd.describe_option('display').
您可以像这样暂时为此一次设置一个选项:
You can set an option only temporarily for this one time like this:
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
您还可以像这样将选项重置为其默认值:
You can also reset an option back to its default value like this:
pd.reset_option('display.max_rows')
然后将它们全部重置:
pd.reset_option('all')
这篇关于 pandas :设置编号.最大行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:pandas :设置编号.最大行数
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 沿轴计算直方图 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
