我在Jupyter Lab中使用pandas 0.25.1,无论pd.options.display.max_rows设置为什么,我可以显示的最大行数都是10。
但是,如果pd.options.display.max_rows设置为小于10,则它将生效,如果设置为pd.options.display.max_rows = None,则显示所有行。
你知道怎么让pd.options.display.max_rows大于10才能生效吗?
发布于 2019-09-10 05:27:45
截至pandas v0.25.1的最终答案
要显示所有行,请在数据帧截断时设置大于DataFrame.
min_rows。
max_rows为200且min_rows为20,则从头到尾的10将显示超过200行的数据,如果max_rows为200且<代码>D15是<代码>D16,将显示来自头部的100和来自尾部的100。发现和注释:
pd.set_option('display.max_rows', x)和pd.options.display.max_rows = x (其中x是某个数字)应该都可以工作。
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行。根据熊猫的文档:
display.max_rows:default=60display.min_rows:default=10display.large_repr:default=truncatemax_rows/max_cols,则repr (和HTML )可以显示截断表(默认值),或者从df.info()切换到视图(早期版本的pandas中的行为)。允许的设置,‘truncate’,‘info’发布于 2021-03-05 11:49:10
min_rows显示从顶部(头部)开始显示的行数,从底部(尾部)开始显示的行数将均匀地split..despite,并放入一个奇数。如果您只想显示一定数量的行,而不想将其读入内存,
另一种方法是使用nrows = 'putnumberhere'。
e.g. results = pd.read_csv('ex6.csv', nrows = 5) # display 5 rows from the top 0 - 4
如果数据帧大约有100行,并且您只想显示top...NO尾部的前5行,请使用.nrows
https://stackoverflow.com/questions/57860775
复制相似问题