I have got three different .csv files which contain the grades for students in three different assignment. I would like to read them with pandas and calculate the average for each student. The template for each file is:
Student id, Mark, extra fields, ...
4358975489, 9, ... ...
2345234523, 10, ... ...
7634565323, 7, ... ...
7653563366, 7, ... ...
... ..., ... ...
For the second assignment:
Student id, Mark, extra fields, ...
4358975489, 6, ... ...
2345234523, 8, ... ...
7634565323, 4, ... ...
7653563366, 5, ... ...
... ..., ... ...
Desired output for the two doc for instance:
Student id, average, extra fields, ...
4358975489, 7.5, ... ...
2345234523, 9, ... ...
7634565323, 5.5, ... ...
7653563366, 6, ... ...
... ..., ... ...
the same for the last doc. I want to read these docs separately and for each student id to average the Mark.
Now, my code for reading one file is the following:
i_df1 = pandas.read_csv('first.csv')
i_df2 = pandas.read_csv('second.csv')
i_df3 = pandas.read_csv('third.csv')
print (o_df.keys())
for i, row in i_df1.iterrows():
pdb.set_trace()
How can I process all three files simultaneously and extract the average grade?
pd.concat([i_df1, i_df2, i_df3]).groupby('Student id').mean().