Python / Data Science Essentials Interview Questions
What does a typical exploratory data analysis (EDA) workflow look like in Python?
EDA is the first thing you do with a new dataset before any modelling. The goal is to understand the data's structure, quality, and relationships, and to spot problems (wrong dtypes, missing values, outliers, data leakage) before they propagate into a model.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# 1. Load and inspect
df = pd.read_csv('housing.csv')
print(df.shape) # (rows, cols)
print(df.dtypes) # types per column
print(df.head()) # first 5 rows
print(df.info()) # dtypes + non-null counts
print(df.describe()) # summary stats for numeric cols
# 2. Missing value audit
missing = df.isnull().sum().sort_values(ascending=False)
print(missing[missing > 0])
# 3. Duplicate rows
print(df.duplicated().sum())
df = df.drop_duplicates()
# 4. Distribution of each numeric column
df.select_dtypes('number').hist(bins=30, figsize=(16, 10))
plt.tight_layout(); plt.show()
# 5. Correlation heatmap
corr = df.select_dtypes('number').corr()
sns.heatmap(corr, annot=True, fmt='.2f', cmap='coolwarm')
plt.title('Correlation Matrix'); plt.show()
# 6. Target variable distribution
target = 'price'
sns.histplot(df[target], kde=True)
print(f'Skewness: {df[target].skew():.2f}')
# 7. Categorical breakdown
for col in df.select_dtypes('object').columns:
print(df[col].value_counts())
# 8. Outlier detection
for col in df.select_dtypes('number').columns:
Q1, Q3 = df[col].quantile([0.25, 0.75])
IQR = Q3 - Q1
n_out = ((df[col] < Q1-1.5*IQR)|(df[col] > Q3+1.5*IQR)).sum()
if n_out > 0: print(f'{col}: {n_out} outliers')EDA is iterative — findings in step 4 send you back to step 2, insights in the correlation matrix raise questions answered by group analysis. Keep a notebook with your observations alongside the code so you and your team can understand what was found and why certain preprocessing decisions were made.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
