0
0
Data Analysis Pythondata~30 mins

Heatmaps for correlation in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Heatmaps for correlation
📖 Scenario: You work as a data analyst for a retail company. You have collected sales data for different products and want to understand how the sales of these products relate to each other. Visualizing these relationships can help the team make better decisions.
🎯 Goal: Build a heatmap to visualize the correlation between sales of different products using Python.
📋 What You'll Learn
Create a pandas DataFrame with sales data for 4 products over 5 days.
Create a variable to store the correlation matrix of the DataFrame.
Use seaborn to create a heatmap of the correlation matrix.
Display the heatmap with clear labels.
💡 Why This Matters
🌍 Real World
Correlation heatmaps help businesses understand how different products' sales relate, guiding marketing and inventory decisions.
💼 Career
Data analysts and scientists use correlation heatmaps to quickly spot patterns and relationships in data, which is essential for data-driven decision making.
Progress0 / 4 steps
1
Create sales data DataFrame
Create a pandas DataFrame called sales_data with these exact columns and values:
'Product_A': [10, 15, 14, 20, 18], 'Product_B': [8, 12, 11, 19, 17], 'Product_C': [5, 7, 6, 9, 8], 'Product_D': [12, 18, 16, 22, 20].
Data Analysis Python
Hint

Use pd.DataFrame and pass a dictionary with product names as keys and lists of sales as values.

2
Calculate correlation matrix
Create a variable called correlation_matrix that stores the correlation matrix of sales_data using the corr() method.
Data Analysis Python
Hint

Use sales_data.corr() to get the correlation matrix.

3
Create heatmap of correlation matrix
Import seaborn as sns and matplotlib.pyplot as plt. Use sns.heatmap() to create a heatmap of correlation_matrix with annotations enabled (annot=True).
Data Analysis Python
Hint

Use sns.heatmap(correlation_matrix, annot=True) to create the heatmap.

4
Display the heatmap
Use plt.show() to display the heatmap plot.
Data Analysis Python
Hint

Use plt.show() to display the plot window.