text_plain_output_1.png
import pandas as pd

df = pd.read_csv('/kaggle/input/students-performance-in-exams/StudentsPerformance.csv')

df.count()

avg_all_test_completed = df[df['test preparation course'] == 'completed']['math score'].mean()
avg_all_test_none = df[df['test preparation course'] == 'none']['math score'].mean()
print('avg_all_test_completed:', avg_all_test_completed)
print('avg_all_test_none:', avg_all_test_none)
avg_men_test_completed = df[(df['test preparation course'] == 'completed') & (df['gender'] == 'male')]['math score'].mean()
avg_men_test_none = df[(df['test preparation course'] == 'none') & (df['gender'] == 'male')]['math score'].mean()
print('avg_men_test_completed:', avg_men_test_completed)
print('avg_men_test_none:', avg_men_test_none)
avg_female_test_completed = df[(df['test preparation course'] == 'completed') & (df['gender'] == 'female')]['math score'].mean()
avg_female_test_none = df[(df['test preparation course'] == 'none') & (df['gender'] == 'female')]['math score'].mean()
print('avg_female__test_completed:', avg_female_test_completed)
print('avg_female_test_none:', avg_female_test_none)