我有以下代码:
raw_data = [[1, 2, 3], [4, 5, 6]]
df = pd.DataFrame(data=raw_data,
columns=["cA", "cB", "cC"])
wrong_indexes = df.loc[df['cA'] > 2 ]
print(wrong_indexes)
这打印:
cA cB cC
1 4 5 6
而不是这个,我想只得到这个条件所持有的索引列表,如下所示:
[1]
知道我怎么能这样做吗?
wrong_indexes = df.loc[df['cA'] > 2 ].index.tolist()