2024-06-03 03:55:55 发布
网友
我在一个数据帧中有100个值,我想使用tabulate打印一个漂亮的表。这对我很有用:
tabulate
print(tabulate(dat], headers='keys', tablefmt='psql'))
现在,这个打印出整个数据帧。我无法在此处获取相关的切片信息:Understanding Python's slice notation
但是我想打印出前5个值,然后是一些...,然后是最后5个值
...
示例:
4 2 1 5 1 . . 4 1 2 4 5
我该怎么做
您将需要set_option,在您的情况下,最大行应该是10,头5和尾5
set_option
For example s=pd.Series([1,2,3,4,5,6,7,8,9,10,11,12]) pd.set_option('max_rows', 10) s Out[1443]: 0 1 1 2 2 3 3 4 4 5 .. 7 8 8 9 9 10 10 11 11 12 Length: 12, dtype: int64
您将需要
set_option
,在您的情况下,最大行应该是10,头5和尾5相关问题 更多 >
编程相关推荐