3 回答

TA贡献1816条经验 获得超4个赞
注意:要显示前几行,也可以使用head。
但是,如果列数多于列display.max_columns或列数多于列display.width(对于行类似),大熊猫将显示摘要视图,因此您需要增加这些列以显示表格视图。您可以使用set选项更改它们,例如:
pd.options.display.max_columns = 50
请参见以下熊猫问题:“ IPython笔记本中具有宽数据框的不直观的默认行为”。
或者,为您可以使用的前几列显示前几行:
df.head(5)[df.columns[0:4]]
# alternatively
df.iloc[:5, :4]

TA贡献1818条经验 获得超11个赞
简短答案:如果您的版本晚于0.11.0,请尝试使用以下方法设置显示宽度:
pd.set_option('display.width', 200)
长答案:当然,该线程已有4个月了,但昨晚我也遇到了同样的问题。一个在我的工作上表现很好的ipython笔记本不会在家中显示html表。
首先,检查您的版本:
import pandas as pd
pd.__version__
我的回来了:'0.11.0'
接下来,使用以下命令检查您的设置:
pd.describe_option('display')
这将为您列出所有可能的显示选项和当前的默认值。您可能需要更改默认设置。选择较大的值可使它正常工作,然后根据需要进行缩小。
Display.width是重要的。我把这些放在进口的首位。
pd.set_option('display.height', 500)
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 200)
添加回答
举报