Calculate the correlation

Report a typo

You have a tiny dataset that contains information on eight students: their age, number of hours they spent preparing to the exam, and their exam grade. Here it is:

+----+---------+-------+--------------+
|    |   hours |   age |   exam_grade |
|----+---------+-------+--------------|
|  0 |      10 |    20 |           76 |
|  1 |      15 |    22 |           80 |
|  2 |      16 |    21 |           83 |
|  3 |      18 |    20 |           80 |
|  4 |      12 |    19 |           75 |
|  5 |      11 |    20 |           70 |
|  6 |      17 |    20 |           85 |
|  7 |      12 |    20 |           78 |
+----+---------+-------+--------------+

Your task is to calculate and print the correlation matrix. Put your code inside the print() in the last line.

Write a program in Python 3
import pandas as pd

exam = pd.DataFrame({
"hours": [10, 15, 16, 18, 12, 11, 17, 12],
"age": [20, 22, 21, 20, 19, 20, 20, 20],
"exam_grade": [76, 80, 83, 80, 75, 70, 85, 78]})

# your code here
print()
___

Create a free account to access the full topic