1

I have the following dataframe:

    layer   idx FP_part     accuracy
    conv2d  0   Mantissa    0.683099
    conv2d  1   Mantissa    0.683099
    conv2d  2   Mantissa    0.683099
    conv2d  3   Mantissa    0.683099
    conv2d  4   Mantissa    0.683099
    conv2d  0   Mantissa    0.683099
    conv2d  1   Exponent    0.683099
    conv2d  2   Exponent    0.683099
    conv2d  3   Exponent    0.683099
    conv2d  4   Exponent    0.683099
    dense_2 0   Mantissa    0.682965
    dense_2 1   Mantissa    0.682836
    dense_2 2   Mantissa    0.682940
    dense_2 3   Mantissa    0.416586
    dense_2 4   Mantissa    0.682983
    dense_2 0   Exponent    0.682965
    dense_2 1   Exponent    0.682836
    dense_2 2   Exponent    0.682940
    dense_2 3   Exponent    0.416586
    dense_2 4   Exponent    0.682983

I am trying to get the min accuracy for each layer and FP_part while keeping the index column. this is what I tried, but the idx column is remived

df_wim = df_w.groupby(['layer',"FP_part"])['accuracy'].min().reset_index()

2 Answers 2

1

Try using idxmin instead of min here,

# Get the index of the row with the minimum accuracy value for each group
idx = df.groupby(['layer','FP_part'])['accuracy'].idxmin()

# Select the rows with the minimum accuracy value for each group
df_wim = df.loc[idx]
Sign up to request clarification or add additional context in comments.

Comments

0

You can try :

df_wim=df_w.groupby(by=['layer','FP_part'], sort=True,dropna=True).min([['accuracy']]).reset_index()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.