I have a DataFrame object:
fruit quantity
apple 500
pear 400
orange 300
I wish to search for the smallest value in column quantity
, then get the corresponding value in column fruit
.
Currently my solution is:
df.sort_values(by='quantity',ascending=True)['fruit'][0]
I expect this to return 'orange'
.
Is there a better way to do this?