[英]iloc[[0]] without printing the header
在https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html 中,
df.iloc[[0]]
a b c d
0 1 2 3 4
给出标题a,b,c,d
。
我可以使用print(df.iloc[[0]])
来打印第0行,但它会包含标题。有没有什么方法可以打印而不给出标题?
如果需要没有标题和索引的打印值,请使用DataFrame.to_string
:
print(df.iloc[[0]].to_string(header=None, index=False))
如果只需要打印 2d 数组之类的值,请使用DataFrame.to_numpy
:
print(df.iloc[[0]].to_numpy())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.