【发布时间】:2019-12-28 03:56:20
【问题描述】:
我有以下 pandas 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'
【问题讨论】:
-
试试
ix = df.eval("Col1.isna() and Col2== 'Type1'", engine='python')