gpt4 book ai didi

python - Pandas pd.options.display.max_rows无法正常工作

转载 作者:行者123 更新时间:2023-12-04 12:02:44 35 4
gpt4 key购买 nike

我在Jupyter Lab中使用的是 Pandas 0.25.1,无论将pd.options.display.max_rows设置为什么,我最多可以显示10行。

但是,如果pd.options.display.max_rows设置为小于10,则生效,如果pd.options.display.max_rows = None,则显示所有行。

知道如何使超过10的pd.options.display.max_rows生效吗?

最佳答案

截至pandas v0.25.1的最终答案

  • 要显示所有行,请将max_rows设置为大于DataFrame中的行数。
  • 要在数据帧被截断时显示多于10行,请将min_rows设置为大于10。
  • 如果数据行超过200行,则max_rows为200,而min_rows为20,则将显示从头开始的10和从尾开始的10。
  • 如果数据行超过200行,则max_rows为200,而min_rowsNone,则显示从头开始的100和从尾开始的100。

  • 发现与注释: pd.set_option('display.max_rows', x)pd.options.display.max_rows = x(其中x是一些数字)都应该起作用。
  • 仅供引用:根据pandas.set_option
  • ,默认值为10行
  • Options and settings
  • 这也是Jupyter Lab

  • 其他有用的 pandas选项:
    pd.set_option('display.max_columns', 200)
    pd.set_option('display.max_rows', 100)
    pd.set_option('display.min_rows', 100)
    pd.set_option('display.expand_frame_repr', True)
    get.options返回当前值:
    pd.get_option("display.max_rows")
    更新:
  • 经过一些发现测试后,如果设置大于DataFrame中的行数,则该设置仅显示更多行。
  • 如果为pd.set_option('display.max_rows', 100),但DataFrame有200行,则仅显示10行。
  • 如果为pd.set_option('display.max_rows', 200),但DataFrame有100行,则将显示所有100行。

  • 根据 Pandas 文档:
  • display.max_rows:默认= 60
  • 设置打印各种输出时 Pandas 应输出的最大行数。例如,此值确定是完整打印数据框的repr()还是仅打印截断的或摘要的repr。 “无”值意味着无限。
  • display.min_rows:默认= 10
  • 在截短的repr中显示的行数(超过max_rows时)。当max_rows设置为None或0时被忽略。当设置为None时,遵循max_rows的值。
  • display.large_repr:默认=截断
  • 对于超过max_rows/max_cols的数据帧,repr(和HTML repr)可以显示截断的表(默认值),或从df.info()切换到 View (早期版本的 Pandas 的行为)。允许的设置,['truncate','info']
  • 关于python - Pandas pd.options.display.max_rows无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57860775/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com