📅  最后修改于: 2022-03-11 14:46:33.475000             🧑  作者: Mango
import pandas as pd
import numpy as np
#1
df.index[df['BoolCol'] == True].tolist()
#2
df.index[df['BoolCol']].tolist()
#ex :
df = pd.DataFrame({'fruit1': np.random.choice(['apple', 'orange', 'banana'], 10),
'fruit2': np.random.choice(['apple', 'orange', 'banana'], 10)})
out = df.index[df.fruit1 == df.fruit2].tolist()