Find the row with the maximum value in column C and return the values in...

Given a dataframe, find the row with the maximum value in column 'C' and return the values in columns 'A' and 'B' for that row.

Problem

Given a dataframe df with three columns 'A', 'B', and 'C', find the row with the maximum value in column 'C' and return the values in columns 'A' and 'B' for that row.
Example input:
   A  B  C
0  1  2  3
1  4  5  6
2  7  8  9
Example output:
7, 8

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
# Solution:
# The solution below is optimal because it uses the built-in max function to find the maximum value in column 'C' and then uses the index of that value to return the values in columns 'A' and 'B' for that row.

df.loc[df['C'].idxmax(), ['A', 'B']]

A.I. Evaluation of the Solution

The candidate's solution is optimal and solves the problem.

Evaluated at: 2022-11-15 06:15:42