[Python] Only Displaying the Top N Rows in a Dataframe that was aggregated with statistical...

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    Suppose I have this

    ISresult = h25.groupby(['month','impactedservice']).agg({'resolvetime': ['count','median','mean', 'min', 'max','std']})

    The column list looks like this:

    [('resolvetime', 'count'), ('resolvetime', 'median'), ('resolvetime', 'mean'), ('resolvetime', 'min'), ('resolvetime', 'max'), ('resolvetime', 'std')]

    What is a good way to only show let's say the Top N or the Bottom N {Month,ImpactedService} pairs going against a measure such as Mean? Keeping the default order of {Month, ImpactedService} is fine, just want to restrict the output to Top N or Bottom N.

    Continue reading...

Compartilhe esta Página