I have a dataframe df:
a b c
d e f g h i
a 12 13 23 5 3 13
b 5 43 31 31 41 76
c 14 13 4 24 20 12
I want to get the series that contains the lowest value, so in this case df[('c', 'h')]
. How can I code this?
You can try stack
with idxmin
:
df[df.stack([0, 1]).idxmin()[1:]]
Result:
a 3
b 41
c 20
Name: (c, h), dtype: int64
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.