Think of a Series as a list of measurements with labels attached. idxmin() returns the index label belonging to its smallest value, letting you locate the minimum without manually comparing rows. section 1.15
Locate a minimum value
For a Series s, s.idxmin() gives the index of one minimum element. If several elements share the minimum, idxmin() returns only one location. To find every tied location, build a boolean mask with s == s.min(), then use s.loc[s == s.min()]. section 1.15
Return a date instead of a row number
When dates form a DataFrame index, df.set_index('date').idxmin() returns the date associated with the minimum value column. The matching idxmax() call finds the date of the maximum; agg(['idxmin', 'idxmax']) obtains both in one operation. section 3.17
Use the result with these distinctions in mind:
- Use idxmin() when one minimum location is sufficient. section 1.15
- Use boolean masking when every tied minimum must be selected or modified. section 1.15
