70.2k views
4 votes
Eight students' grades in the respective courses are given via this dictionary:

{'Math' : [80, 89, 93, 66, 84, 85, 74, 64],
'Science' : [94, 76, 88, 78, 88, 92, 60, 85],
'English' : [83, 76, 93, 96, 77, 85, 92, 60],
'History' : [96, 66, 76, 85, 78, 88, 69, 99]}
Form the corresponding pandas dataframe and report the means and standard
deviations by student and by course. Provide the 5-number summary for each

1 Answer

3 votes

Final Answer:

Here's is the pandas library in Python to create a DataFrame from the given data:

```python

import pandas as pd

# Given data

grades = {

'Math': [80, 89, 93, 66, 84, 85, 74, 64],

'Science': [94, 76, 88, 78, 88, 92, 60, 85],

'English': [83, 76, 93, 96, 77, 85, 92, 60],

'History': [96, 66, 76, 85, 78, 88, 69, 99]

}

# Create a DataFrame

d.f = pd.DataFrame(grades)

# Calculating means and standard deviations by student

student_means = d.f.mean(axis=1)

student_std_dev = d.f.std(axis=1)

# Calculating means and standard deviations by course

course_means = d.f.mean()

course_std_dev = d.f.std()

# 5-number summary by course

course_summary = d.f.. describe().loc[['min', '25%', '50%', '75%', 'max']]

# 5-number summary by student

student_summary = df. describe(percentiles=[])

print("Means by student:")

print(student_means)

print("\\Standard deviations by student:")

print(student_std_dev)

print("\\Means by course:")

print(course_means)

print("\\Standard deviations by course:")

print(course_std_dev)

print("\\5-number summary by course:")

print(course_summary)

print("\\5-number summary by student:")

print(student_summary)

```

Step-by-step explanation:

This code will create a DataFrame, calculate means and standard deviations by both students and courses, and provide the 5-number summary for each course and student based on their grades in the given dictionary.

This Python code utilizes the pandas library to create a DataFrame from a dictionary containing eight students' grades across four courses. It computes means and standard deviations for both students and courses, revealing average performance and the spread of grades.

Additionally, the code generates a 5-number summary—minimum, 25th percentile, median, 75th percentile, and maximum—displaying the distribution of grades in each course and summarizes statistics for individual student performances, offering a comprehensive overview of the dataset's central tendencies, variability, and distribution characteristics for both courses and students.

User Pvomhoff
by
7.6k points