擅长:python、mysql、java
<p>可以使用只有唯一值的集合。如果一行有3个相等的值,那么
len(set(row))=len(row)-2。
遍历数据帧以查找这些行并存储它们的索引。你知道吗</p>
<pre><code>indexes_to_remove = []
for index, row in df.iterrows():
if len(set(row)) < len(row) - 2:
indexes_to_remove.append(index)
</code></pre>
<p>然后你就可以安全地移除它们了。你知道吗</p>