# Heat Map - Hindustan Unilever Limited (1 year data)

Published: 18 December 2023| Version 1 | DOI: 10.17632/m9777t52kc.1
Contributor:
Sunil Maria Benedict

## Description

Data Reading and Preparation: Imports the required libraries: pandas, seaborn, and matplotlib.pyplot. Reads the CSV file containing financial data of a stock (HINDUNILVR.NS.csv) using Pandas' read_csv() function. Selects numeric columns (excluding non-numeric) from the dataset using select_dtypes() based on the specified data types (int64 and float64). Correlation Analysis: Calculates the correlation matrix using the corr() function on the selected numeric columns. This matrix displays the correlation coefficients between pairs of numeric variables. Visualization: Generates a heatmap using Seaborn's heatmap() function to visualize the correlation matrix. The heatmap depicts the strength and direction of relationships between the selected numeric columns using color gradients. Higher positive correlations are shown in warmer tones (e.g., red), while negative correlations are represented in cooler tones (e.g., blue). The color intensity signifies the strength of the correlation. The annot=True parameter adds the correlation coefficient values to the heatmap cells. The title "Correlation Between Numeric Columns" is added to the heatmap. The resulting visualization, presented as a heatmap, offers an intuitive way to interpret and understand the relationships between different numeric variables in the financial dataset. Strong correlations (positive or negative) are highlighted, aiding in identifying potential patterns or dependencies among the variables. The numerical annotations provide exact correlation values, facilitating a more detailed analysis of the relationships within the dataset.

## Steps to reproduce

import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Read the CSV file into a DataFrame df = pd.read_csv('/Users/sunilbenedict/Documents/HINDUNILVR.NS.csv') # Correlation Between Numeric Columns (excluding non-numeric) numeric_df = df.select_dtypes(include=['int64', 'float64']) # Adjust these data types accordingly # Calculate correlation matrix correlation_matrix = numeric_df.corr() # Plotting correlation heatmap plt.figure(figsize=(10, 8)) sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt=".2f") plt.title('Correlation Between Numeric Columns') plt.show()

## Categories

Correlation Analysis, Stock Exchange, Stock Price, Heat Map