我试图在ipython笔记本上打印df,但它没有将其打印为表。在
data = {'year': [2010, 2011, 2012, 2011, 2012, 2010, 2011, 2012],
'team': ['Bears', 'Bears', 'Bears', 'Packers', 'Packers', 'Lions', 'Lions', 'Lions'],
'wins': [11, 8, 10, 15, 11, 6, 10, 4],
'losses': [5, 8, 6, 1, 5, 10, 6, 12]}
football = pd.DataFrame(data, columns=['year', 'team', 'wins', 'losses'])
print football
输出
^{pr2}$我按照建议尝试了“显示”:Show DataFrame as table in iPython Notebook:
from IPython.display import display
#.....
print display(football)
也尝试过:
pandas.core.format.set_printoptions(notebook_repr_html=True)
但有个错误:
AttributeError: 'module' object has no attribute 'set_printoptions'
如何将df打印成一个具有良好的垂直和水平线的表?在
set_printoptions
已被set_options
替换,在较新版本的pandas中,请尝试使用:也不要使用}。在
print
,只需在笔记本单元格的最后一行中声明football
或{相关问题 更多 >
编程相关推荐