【发布时间】:2018-07-23 11:29:53
【问题描述】:
我检查了w_table.iloc[i,4] 并没有在其中找到NoneType 对象。怎么回事?
check = ['word']
for i in range(len(w_table)):
if w_table.iloc[i, 4] != 'Null':
if w_table.iloc[i, 4] in check:
w_table = w_table.drop(w_table.index[i])
else:
check = check.append(w_table.iloc[i, 4])
w_table.index = np.arange(len(w_table))
执行上述代码后,我开始关注TypeError
TypeError Traceback (most recent call
last) <ipython-input-74-40b9156195fa> in <module>()
2 for i in range(len(w_table)):
3 if w_table.iloc[i, 4] != 'Null':
4 if w_table.iloc[i, 4] in check:
5 w_table = w_table.drop(w_table.index[i])
6 else:
TypeError: argument of type 'NoneType' is not iterable
【问题讨论】:
-
欢迎来到 StackOverflow。请花时间阅读how to provide a great pandas example 上的这篇文章以及如何提供minimal, complete, and verifiable example 并相应地修改您的问题。 how to ask a good question 上的这些提示也可能有用。
-
但似乎问题出在
NaNs,列中缺少值。 -
你能提供一个
w_table的例子并描述你想要做什么吗?通常循环遍历 DataFrame 并不是最好的主意,这里可能有更简单的解决方案。 -
@jezrael 列中没有“Nan”
-
if pd.notnull(w_table.iloc[i, 4])工作怎么样?
标签: python pandas ipython nonetype