Correlation with corr()
📖 Scenario: You are a data analyst working with a small dataset of students' scores in two subjects: Math and English. You want to find out if there is a relationship between their scores in these subjects.
🎯 Goal: Build a simple Python program that creates a dataset of students' scores, sets up a DataFrame, calculates the correlation between Math and English scores using corr(), and prints the result.
📋 What You'll Learn
Create a dictionary called
scores with keys 'Math' and 'English' and the exact values: [88, 92, 79, 93, 85] and [84, 90, 78, 88, 82] respectivelyImport
pandas as pdCreate a DataFrame called
df from the scores dictionaryCalculate the correlation between the
'Math' and 'English' columns using df['Math'].corr(df['English']) and store it in a variable called correlationPrint the
correlation variable💡 Why This Matters
🌍 Real World
Correlation helps to find relationships between variables, like how scores in one subject relate to another. This is useful in education, business, and science.
💼 Career
Data analysts and scientists use correlation to understand data patterns and make decisions based on relationships between variables.
Progress0 / 4 steps