I have a dataset in a csv file that looks like this:
teacher         student         student grade
Jon             marin           99
Jon             Rob             81
Jon             marly           90
Bon             martin          76
Bon             marie           56
Ton             Seri            43
Ton             Loku            99
I need an output that has the average of each teacher based on the grades obtained by student. Which will look like this,
teacher         student         student grade       teacher Average
Jon             marin           99                  90
Jon             Rob             81                  90
Jon             marly           90                  90
Bon             martin          76                  66
Bon             marie           56                  66
Ton             Seri            43                  71
Ton             Loku            99                  71
What is the shortest possible way to get this ?
This is my approach but it does not seem to work.
import pandas as pd
df = pd.read_csv('test.csv', names=['teacher', 'student', 'student grade','Average'])
df.groupby('Star Rating').mean()