【发布时间】:2022-09-23 01:59:44
【问题描述】:
有人可以帮我解决这个问题。我想按名称调用行,所以我在数据框中的第一列使用 set_index 来按名称索引行,而不是使用整数进行索引。
# Set \'Name\' column as index on a Dataframe
df1 = df1.set_index(\"Name\", inplace = True)
df1
输出:
AttributeError: \'NoneType\' object has no attribute \'set_index\'
然后我运行以下代码:
result = df1.loc[\"ABC4\"]
result
输出:
AttributeError: \'NoneType\' object has no attribute \'loc\'
在修复错误之前,我通常不会运行依赖于第一个代码的第二个代码,但最初我在一个 Jupyter 笔记本单元格中将它们一起运行。现在我看到这两个代码单元有问题。
请让我知道我哪里出错了。谢谢!
标签: python indexing jupyter-notebook in-place