Spaces:
Sleeping
Sleeping
File size: 1,183 Bytes
b12e4cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
{
"cells": [
{
"cell_type": "markdown",
"id": "86625251",
"metadata": {},
"source": [
"# Assignment 4: EDA - Correlation Analysis\n",
"Perform correlation analysis on a dataset of car features and prices.\n",
"Calculate correlation matrix and plot a heatmap."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d3ae5847",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Synthetic dataset\n",
"data = {\n",
" 'horsepower': [120, 150, 100, 180],\n",
" 'weight': [3000, 3200, 2800, 3500],\n",
" 'price': [20000, 25000, 18000, 30000]\n",
"}\n",
"df = pd.DataFrame(data)\n",
"\n",
"# Correlation matrix\n",
"corr_matrix = df.corr()\n",
"\n",
"# Plot heatmap\n",
"sns.heatmap(corr_matrix, annot=True)\n",
"plt.title('Correlation Heatmap')\n",
"plt.show()\n",
"\n",
"# Error: Incorrect column name\n",
"print(df['Price'])"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|