Skip to content
Advertisement

Finding minimum value with groupby() by comparing two columns

I am trying to find a minimum number using groupby() by comparing two columns (Each containing a time duration)

Sample data:

JavaScript

Sample code: (It works for 1 column only)

JavaScript

I want to group my data by groupby('Centroid_ID') by comparing Regular_Ambu_TT and MSU_TT to get a minimum value.

Advertisement

Answer

Here is one approach

  1. Get the min per column
  2. Get a min per row to get the final minimum .
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement