gpt4 book ai didi

python - 命令在没有索引的情况下打印前 10 行 python pandas 数据帧?

转载 作者:行者123 更新时间:2023-12-04 16:41:17 27 4
gpt4 key购买 nike

head()打印索引。dataframe.to_string(index=False,max_rows=10)打印前 5 行和后 5 行。

最佳答案

你应该试试这个:

print(df.head(n=10).to_string(index=False))

这会起作用,因为 df.head返回 Dataframe对象,以便您可以应用 to_string方法并摆脱该索引^^。

关于python - 命令在没有索引的情况下打印前 10 行 python pandas 数据帧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60357116/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com