0

I have a dataframe like that (was made in pandas):

    1   2   3
0   A   1   v
1   A   5   b
2   B   4   d
3   B   7   r

I want to grout it to view like that:

    1   2   3
0   A   1   v
1   B   4   d

I mean that I want to group df by the first column, from the second column the minimum value must be selected and from the third column must be selected value which corresponds to the minimum value from the second column.

How can I do this (third column is interesting)

Yuri
  • 1
  • Your question has been asked and answered before. But, I'll still provide a solution specific to your dataset `df.loc[df.groupby([1])[2].idxmin()] ` – Matthew Thomas Oct 10 '22 at 21:28

0 Answers0