EDA is the first and most important step in any data analytics or machine learning project. It helps you understand the data, spot patterns, detect outliers, and prepare for modeling.
1๏ธโฃ Load and Understand the Data
import pandas as pd
df = pd.read_csv("sales_data.csv")
print(df.head())
print(df.shape)
Goal: Get the structure (rows, columns), data types, and sample values.
2๏ธโฃ Summary and Info
df.info()
df.describe()
Goal:
โข See null values
โข Understand distributions (mean, std, min, max)
3๏ธโฃ Check for Missing Values
df.isnull().sum()
๐ Fix options:
โข
df.fillna(0) โ Fill missing valuesโข
df.dropna() โ Remove rows with nulls4๏ธโฃ Unique Values Frequency Counts
df['Region'].value_counts()
df['Product'].unique()
Goal: Understand categorical features.
5๏ธโฃ Data Type Conversion (if needed)
df['Date'] = pd.to_datetime(df['Date'])
df['Amount'] = df['Amount'].astype(float)
6๏ธโฃ Detecting Duplicates Removing
df.duplicated().sum()
df.drop_duplicates(inplace=True)
7๏ธโฃ Univariate Analysis (1 Variable)
import seaborn as sns
import matplotlib.pyplot as plt
sns.histplot(df['Sales'])
sns.boxplot(y=df['Profit'])
plt.show()
Goal: View distribution and detect outliers.
8๏ธโฃ Bivariate Analysis (2 Variables)
sns.scatterplot(x='Sales', y='Profit', data=df)
sns.boxplot(x='Region', y='Sales', data=df)
9๏ธโฃ Correlation Analysis
sns.heatmap(df.corr(numeric_only=True), annot=True)
Goal: Identify relationships between numerical features.
๐ Grouped Aggregation
df.groupby('Region')['Revenue'].sum()
df.groupby(['Region', 'Category'])['Sales'].mean()
Goal: Segment data and compare.
1๏ธโฃ1๏ธโฃ Time Series Trends (If date present)
df.set_index('Date')['Sales'].resample('M').sum().plot()
plt.title("Monthly Sales Trend")
๐ง Key Questions to Ask During EDA:
โข Are there missing or duplicate values?
โข Which products or regions perform best?
โข Are there seasonal trends in sales?
โข Are there outliers or strange values?
โข Which variables are strongly correlated?
๐ฏ Goal of EDA:
โข Spot data quality issues
โข Understand feature relationships
โข Prepare for modeling or dashboarding
๐ฌ Tap โค๏ธ for more!