I have Two data frames
import pandas as pd
exam_1 = pd.DataFrame({'user': ['A', 'B', 'C'],
'marks': [10, 50, 40]})
exam_2 = pd.DataFrame({'user': ['A', 'C', 'D'],
'marks': [30, 20, 30]})
I’m trying to get a resultant data frame, with users appeared in both exams with lowest marks.
In the above example result should be:
user marks
A 10
C 30
I did write following lines to get users who appeared in both exams but, stuck in getting the lowest marks. Here is what I have tried
tmp = pd.merge(exam_1, exam_2, how='inner', on=['user'])
USERS = exam_1[ exam_1['user'].isin(tmp['user'])]
can someone please help me to get lowest exam marks in the resultant dataframe?