问题描述
我有一个庞大的数据框,但出现错误:
I have a massive dataframe, and I'm getting the error:
TypeError :(空'DataFrame':没有要绘制的数字数据",出现在索引159220上)"
我已经删除了空值,并检查了DataFrame的dtypes,所以我不知道为什么它在那一行上失败了.
I've already dropped nulls, and checked dtypes for the DataFrame so I have no guess as to why it's failing on that row.
如何仅打印数据帧的那一行(索引159220)?
How do I print out just that row (at index 159220) of the data frame?
谢谢
推荐答案
当您使用标量值调用 loc
时,会得到一个 pd.Series
.然后,该系列将具有一个 dtype
.如果要查看数据帧中的行,则需要将类似索引器的数组传递给 loc
.
When you call loc
with a scalar value, you get a pd.Series
. That series will then have one dtype
. If you want to see the row as it is in the dataframe, you'll want to pass an array like indexer to loc
.
用另外一对方括号包裹索引值
Wrap your index value with an additional pair of square brackets
print(df.loc[[159220]])
这篇关于如何打印 pandas DataFrame的特定行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!