这个问题在这里已经有了答案:
Is there a pandas function to display the first/last n columns, as in .head() & .tail()?
(5 个回答)
6年前关闭。
我有一个包含大约 500 列的数据框,这就是为什么我想知道是否可以使用 head() 函数但想查看前 50 列。
谢谢
最佳答案
我不确定你是指行还是列。
如果是行,那么
df.head(50)
会做的伎俩。
如果是列,那么
df.iloc[:, : 50]
将工作。
当然,您可以将它们组合起来。
你可以在 Indexing and Selecting Data 看到这些东西.
关于Pandas 数据框前 x 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30673684/