Hello I have two ratio calculted dataframe. I am taking average of each rows accross column to get one value average when am doing like that both average proportion are not matching in dataframes
df1
name exm1 exm2 exm3 exm4
student1 0.43 0.36 0 1
student2 0 0 0 0.45
student3 0 0 0 0
student4 0.64 0 0.75 0.6
student5 0.12 0.23 0.57 0
student6 0 0 0 0.9
student7 0 1 0 0.3
student8 0.43 0.36 0 0.25
student9 0 0 0 0.58
student10 0 0 0 0
df2
name exm1 exm2 exm3 exm4
student1 0.57 0.64 0 0
student2 0 0 0 0.55
student3 0 0 0 1
student4 0.36 0 0.25 0.4
student5 0.88 0.77 0.43 0
student6 0 0 0 0.9
student7 0 0 0 0.3
student8 0 0 0 0.25
student9 0 0 0 0.58
student10 0 0 0 0
to calculate average I used below code
df1['average'] = df1.mean(numeric_only=True, axis=1)
df2['average'] = df2.mean(numeric_only=True, axis=1)
in both dataframe when comapare average along students average is not equal to 1 the main cause of this is 0 present in both cell. for example student1 in exm3 both its zero this type zeros making average inappropriate
name average_df1 average_df2 sum
student1 0.4475 0.451875 0.899375
student2 0.1125 0.140625 0.253125
student3 0 0 0
student4 0.4975 0.461875 0.959375
student5 0.23 0.2575 0.4875
student6 0.225 0.28125 0.50625
student7 0.325 0.40625 0.73125
student8 0.26 0.2175 0.4775
student9 0.145 0.18125 0.32625
student10 0 0 0
sum of average should be equal to one. how can I can do it in pandas any suggestions