0 Introduction To Data Science - Exercises
0 Introduction To Data Science - Exercises
Exercises
Chapter 7
Exercises
DataFrame
1. Create a DataFrame containing student scores for three subjects: Math, Science, and History.
Include at least 5 students and their respective scores.
2. Add a new column to the DataFrame called "Total" which contains the total score of each student.
3. Calculate the average score for each subject and add it to the DataFrame.
#create a DataFrame
df = pd.DataFrame(data)
print ('Display the DataFrame')
print(df)
print()
DataFrame
2. Add a new column to the DataFrame called "Total" which contains the
total score of each student.
#Filter Students
filtered_df = df[(df['Math'] >= 80) & (df['Science'] >= 80) & (df['History'] >= 80)]
print ('Filter Students')
print(filtered_df)