Feb-16-2022, 04:58 PM
Hi All,
brand new to Python so appreciate the help. I am trying to add a new column, which should be calculated as the mean of 'math score' grouped by 'parental level of education' (attached is the spreadsheet), to an existing .csv file using the following code:
import pandas as pd
# file locations
input_file = "/Users/PYTHON/Exercise/StudentsGrades.csv"
output_file = "/Users/PYTHON/Exercise/"
df = pd.read_csv(input_file)
df.groupby(['parental level of education']).mean()
df['New Column'] = df.groupby
df.to_csv(output_file + 'File_w_Extra_Column.csv')
I keep getting this error: "RecursionError: maximum recursion depth exceeded in __instancecheck__".
I have googled the possible solution but haven't been able to make sense of it.
Appreciate your help!
Mel
StudentsGrades.csv (Size: 791 bytes / Downloads: 272)
brand new to Python so appreciate the help. I am trying to add a new column, which should be calculated as the mean of 'math score' grouped by 'parental level of education' (attached is the spreadsheet), to an existing .csv file using the following code:
import pandas as pd
# file locations
input_file = "/Users/PYTHON/Exercise/StudentsGrades.csv"
output_file = "/Users/PYTHON/Exercise/"
df = pd.read_csv(input_file)
df.groupby(['parental level of education']).mean()
df['New Column'] = df.groupby
df.to_csv(output_file + 'File_w_Extra_Column.csv')
I keep getting this error: "RecursionError: maximum recursion depth exceeded in __instancecheck__".
I have googled the possible solution but haven't been able to make sense of it.
Appreciate your help!
Mel
