命令打印没有索引的 python pandas 数据帧的前 10 行?

Cor*_*hes 6 python dataframe pandas

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

小智 7

你应该尝试这个:

print(df.head(n=10).to_string(index=False))
Run Code Online (Sandbox Code Playgroud)

这将起作用,因为df.head返回一个Dataframe对象,因此您可以to_string对其应用该方法并删除该索引^^。