← 30 Days of Python
Day 30 / 30Mock Interview

Python Mock Interview — Real Questions & Model Answers

Day 30. This is your mock interview. These are real questions asked in data analyst Python interviews at companies like Genpact, Wipro, HCL, Meesho, PhonePe, and analytics agencies across Delhi NCR. Answer each one before reading the model answer.

1
Easy

How is Python different from Excel for data analysis, and when would you use one over the other?

Python Answer
Excel: pivot tables, charts, quick one-time analysis, sharing with non-technical stakeholders. Best for < 100K rows, interactive exploration.

Python: automation, 1M+ rows, complex transformations, reproducibility, APIs, scheduling, ML. Best when the same task runs repeatedly or on large data.

I use Excel for quick stakeholder reports and Python when building a repeatable pipeline or working with data too large for Excel.
💡

Interviewers want to know you understand both tools and can choose the right one. Showing pragmatism (using the right tool, not always Python) demonstrates professional maturity.

2
Medium

You have a DataFrame with 500K rows. A column "purchase_date" is stored as a string in format "DD-MM-YYYY". Write the code to convert it and extract the year and month.

Python Answer
df["purchase_date"] = pd.to_datetime(df["purchase_date"], format="%d-%m-%Y")
df["year"]  = df["purchase_date"].dt.year
df["month"] = df["purchase_date"].dt.month

# Verify:
print(df[["purchase_date","year","month"]].head())
💡

Always specify format= for non-standard date strings — it is 5x faster than auto-parsing on 500K rows. dt.year and dt.month are vectorised, no loop needed. The print verify shows you test your own code.

3
Medium

A column "revenue" has 1,200 null values out of 50,000 rows. How do you handle this?

Python Answer
# Step 1: Check percentage:
null_pct = df["revenue"].isnull().sum() / len(df) * 100  # 2.4%

# Step 2: Understand why — random or systematic?
df[df["revenue"].isnull()].describe()  # any pattern?

# Step 3: Choose strategy:
# If 2.4% and random → fill with median
df["revenue"] = df["revenue"].fillna(df["revenue"].median())

# If nulls cluster in a segment → fill by group mean:
df["revenue"] = df.groupby("region")["revenue"].transform(
    lambda x: x.fillna(x.median())
)
💡

2.4% null rate is low — imputation is appropriate. Always understand WHY values are missing before deciding how to handle them. Group-level imputation is more accurate than global imputation.

4
Hard

You receive a CSV with 50 columns. How do you quickly identify which columns are useful for analysis?

Python Answer
# Step 1: Nulls:
null_pct = df.isnull().sum() / len(df) * 100
high_null = null_pct[null_pct > 50].index  # >50% null — likely useless

# Step 2: Variance — constant columns:
zero_var = df.select_dtypes("number").columns[df.select_dtypes("number").std() == 0]

# Step 3: Cardinality of categoricals:
for col in df.select_dtypes("object").columns:
    print(col, df[col].nunique())
# 1 unique → useless, 500K unique → likely ID (not analytical)

# Step 4: Correlation with target:
df.corr()["revenue"].sort_values(ascending=False)
💡

Column triage before analysis is a professional skill. Columns with >50% nulls, zero variance, or 1 unique value are almost always dropped. High cardinality strings are IDs, not features. This four-step process shows systematic thinking.

5
Hard

Write Python code to find the top 5 products by revenue for each region.

Python Answer
top5_by_region = (
    df.groupby(["region", "product"])["revenue"]
    .sum()
    .reset_index()
    .sort_values(["region", "revenue"], ascending=[True, False])
    .groupby("region")
    .head(5)
)

print(top5_by_region)
💡

The pattern: sum by region+product → sort by revenue descending within each region → take top 5 per region using groupby().head(5). This is one of the most common interview questions — memorise this exact pattern.

EVIKA ACADEMY · PYTHON FOR DATA ANALYTICS

Want to master Python with live practice?

Join our Python for Data Analysis course — live classes in Noida and online across India.

Book Free Demo Class →
← PREVIOUSDay 29: Python Coding Challenges for AnalystsSERIES COMPLETE →Back to Series Overview
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY