Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

the scoring average of every name in a new column

data = {'Name' : ["ana","ini","unu"],'ID' : ["1027","1028","1029"],'Score1' : [3,5,2], 'Score2' : [5,5,4],'Score3' : [1,2,5]}

how can i know the scoring average?

data["Average"] = data.mean(axis=1)
i tried to use it but didn’t work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It tries to take the average over the entire row, including Name and ID.

df = pd.DataFrame(data)
df["Average"] = df[['Score1', 'Score2', 'Score3']].mean(axis=1)

Output:

>>> df
  Name    ID  Score1  Score2  Score3   Average
0  ana  1027       3       5       1  3.000000
1  ini  1028       5       5       2  4.000000
2  unu  1029       2       4       5  3.666667
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading