我有以下熊猫DataFrame df
:
Col1 Col2
0 NaN Type1
1 NaN Type2
2 NaN Type1
3 A Type1
4 NaN Type1
我需要获取Col1
等于NaN
和Col2
等于的行的索引Type1
。这是我尝试的:
ix = df.eval("Col1.isna() and Col2== 'Type1'")
但这给了我以下错误:
TypeError: unhashable type: 'numpy.ndarray'
做这样的事情:
df.index[df['Col1'].isna() & df['Col2'].eq('Type1')].tolist()
这应该工作,才能够运行它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句