'How to get the maximum value of the same columns from two dataframe
I have two dataframe, df1 and df2 as below. I am trying to create a new dataframe that will show the maximum score for each student across subjects. For example, in the new dataframe, the match_score for George would be 63 (which is the maximum match_score in df1 and df2).
Is there a way to do this? Any advices and suggestion will be greatly appreciated.
import pandas as pd
df1 = { 'student':['George','Andrea','micheal','Ann',
'maggie','Ravi','Xien','Jalpa'],
'match_score':[63,42,56,70,38,78,84,99],
'ela_score':[43,74,41,82,69,46,70,98]}
df2 = { 'student':['George','Andrea','micheal', 'Matt',
'maggie','Ravi','Xien','Jalpa'],
'match_score':[62,47,55,74,32,77,86,77],
'ela_score':[45,78,44,89,66,49,72,73]}
df1=pd.DataFrame(df1)
df2=pd.DataFrame(df2)
Solution 1:[1]
data=pd.concat([df1, df2])
data.match_score.max()
99
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harunur Roshid |
