请检查以下错误...公共列表中存在一些值,因此,我不希望包含公共列表的df_head值…或可以说df_head = df_head - commonlist
commonlist =df_head[df_head['Name'].isin(common)]
df_head not in commonlist
错误来了
TypeError Traceback (most recent call last)
<ipython-input-16-ff85aff2f182> in <module>
----> 1 df_head not in commonlist
~\Anaconda3\lib\site-packages\pandas\core\generic.py in __contains__(self, key)
1520 def __contains__(self, key):
1521 """True if the key is in the info axis"""
-> 1522 return key in self._info_axis
1523
1524 @property
~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in __contains__(self, key)
2033 @Appender(_index_shared_docs['__contains__'] % _index_doc_kwargs)
2034 def __contains__(self, key):
-> 2035 hash(key)
2036 try:
2037 return key in self._engine
~\Anaconda3\lib\site-packages\pandas\core\generic.py in __hash__(self)
1490 def __hash__(self):
1491 raise TypeError('{0!r} objects are mutable, thus they cannot be'
-> 1492 ' hashed'.format(self.__class__.__name__))
1493
1494 def __iter__(self):
TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed
答案 0 :(得分:1)
只需:
df_head[~df_head['Name'].isin(common)]
~
将否定df_head['Name'].isin(common)
的值。
实际上commonlist
并不是必需的,除非您出于其他原因要存储它们。