0

I am a Newbie in python. I have a big dataframe looks like this:

ID  A   B   C
A   12331   A1  CA
A   23445   A1  CA
A   38650   A1  CA
B   12324   B1  BB
B   45356   B1  BB
B   97867   B1  BB
C   34563   C1  CC
C   64577   C1  CC
C   74533   C1  CC

how to delete or drop the row but first (minimum value) still exist. I tried this Keep other columns when using min() with groupby but still not working. my expected result looks like this:

ID  A   B   C
A   12331   A1  CA
B   12324   B1  BB
C   34563   C1  CC

thank you

Arief Hidayat
  • 937
  • 1
  • 8
  • 19
  • Given that minimum values occur at first place and each category (A, B, ..) have 3 entries then just use `df.iloc[::3,0]` – meW Jan 08 '19 at 07:41
  • Do you try `df.loc[df.groupby('ID')['A'].idxmin()]` ? For me it working nice. – jezrael Jan 08 '19 at 08:09

0 Answers0