按条件筛选 pandas

Filtering in pandas by condition

我有一个数据框示例,如下所示。第一行是 header.

a  b   c   d   e
x  1   10  4   asd
y  3   12  5   aqe
z  4   14  6   rty
t  6   12  4   abd
v  7   4   8   yul

我想通过按最小值过滤 d 列来查找列成员。我尝试了排序和 select 0. 元素,但列可能有 2 个最小值,就像示例中的那样。

输出应为 "x" 和 "t"

有什么建议吗?

对 select 列 a 使用 boolean indexing with loc,最后转换为 list:

L = df.loc[df['d'] == df['d'].min(), 'a'].tolist()
print (L)
['x', 't']

详情:

print (df['d'] == df['d'].min())
0     True
1    False
2    False
3     True
4    False
Name: d, dtype: bool