Pandas 获取大熊猫中True的整数位置

Pandas 获取大熊猫中True的整数位置,pandas,Pandas,我需要找到一个True的所有整数位置,例如 df = pd.DataFrame([[True, False], [False, True]], columns=['column0', 'column1'], index=['row0', 'row1']) 输出应为(0,0)、(1,1)或类似值通过获取True值的位置,然后使用zip: i, c = np.where(df) a = list(zip(i, c)) pri

我需要找到一个True的所有整数位置,例如

df = pd.DataFrame([[True, False], [False, True]],
                  columns=['column0', 'column1'],
                  index=['row0', 'row1'])

输出应为(0,0)、(1,1)或类似值

通过获取
True
值的位置,然后使用
zip

i, c = np.where(df)

a = list(zip(i, c))
print (a)
[(0, 0), (1, 1)]
详细信息

print (np.where(df))
(array([0, 1], dtype=int64), array([0, 1], dtype=int64))