Python for Data Analytics
The complete Python journey for aspiring data analysts. Phase 1 (0–2 yrs) and Phase 2 (2–3+ yrs) topics, 17 priority-ranked topics, a 30-60-90 day plan, 5 portfolio projects, real-world scenarios, and interview prep.
Priority-Based Topic Checklist
Organized by Phase (1 and 2). Expand each for context; check off as you master them.
01.Python Fundamentals — Syntax, Data Structures, Functions
Most CriticalEasyPhase 1 2–3 weeksOrder #1● Critical02.Pandas & NumPy — The Core Analytics Engine
Most CriticalEasyPhase 1 4–5 weeksOrder #2● Critical03.Data Cleaning — Real-World Dirty Data Workflows
Must KnowMediumPhase 1 3–4 weeksOrder #3● Critical04.Data Visualization — Matplotlib, Seaborn & Plotly
Must KnowMediumPhase 1 3–4 weeksOrder #4● High05.Daily Analyst Skills — Excel Automation, CSV, Reports
Must KnowMediumPhase 1 2–3 weeksOrder #5● Critical06.Git & Version Control — Non-Negotiable
Must Know Google CriticalMediumPhase 1 1–2 weeksOrder #6● Critical07.Project Structure, venv & Reproducible Environments
Must KnowMediumPhase 1 1 weekOrder #7● Critical08.Testing, Type Hints & Code Quality — Senior-Level Craft
Senior LevelMediumPhase 1 2 weeksOrder #8● High09.Automation — Reporting, Email, Scheduling, ETL Pipelines
Must KnowMediumPhase 2 3–4 weeksOrder #9● High10.SQL + Python Integration — Databases, Queries, Workflows
Must KnowMediumPhase 2 3–4 weeksOrder #10● Critical11.APIs & Web Scraping — External Data Ingestion
Must KnowMediumPhase 2 2–3 weeksOrder #11● High12.Performance — Large Datasets, Memory, Optimization
Senior LevelHardPhase 2 3–4 weeksOrder #12● High13.BI Integration — Power BI, Dashboards, Data Refresh
Must KnowMediumPhase 2 2–3 weeksOrder #13● High14.Advanced Analytics — Statistics, A/B Testing, Forecasting, ML Basics
Senior LevelHardPhase 2 4–6 weeksOrder #14● High15.BigQuery + Python — Google's Core Analytics Stack
Senior Level Google CriticalHardPhase 2 3–4 weeksOrder #15● High16.Jupyter Best Practices — Papermill, nbconvert & Production Notebooks
Must KnowMediumPhase 2 1–2 weeksOrder #16● High17.Automated EDA — ydata-profiling, Looker & Google Workspace APIs
Google CriticalMediumPhase 2 1–2 weeksOrder #17● High
Must Know for Early Data Analysts
Core Python skills every data analyst must master in their first two years. Tested in interviews and used daily.
Python Fundamentals
- ›Variables and data types: int, float, str, bool, None
- ›Collections: lists, tuples, dictionaries, sets
- ›Control flow: if/elif/else, for loops, while loops
- ›Functions: def, args/kwargs, return, lambda
- ›List comprehensions and dict comprehensions
- ›File handling: open, read, write, with context manager
- ›Exception handling: try/except/finally
- ›Modules and imports (os, sys, datetime, re)
- ›OOP basics: class, __init__, methods, inheritance
Pandas Core Operations
- ›DataFrame and Series creation, indexing, slicing
- ›loc vs iloc — label vs position based selection
- ›Filtering: boolean masks, query(), isin()
- ›Sorting: sort_values(), sort_index()
- ›GroupBy: .groupby().agg(), transform(), apply()
- ›Merge, join, concat — combining DataFrames
- ›Pivot tables: pivot_table(), crosstab()
- ›Date/time: pd.to_datetime(), .dt accessor
- ›String operations: .str accessor
- ›Missing values: isnull(), fillna(), dropna()
Data Cleaning Patterns
- ›Duplicate removal: drop_duplicates(subset=, keep=)
- ›Text cleaning: .str.strip(), .str.lower(), .str.replace()
- ›Type casting: pd.to_numeric(errors='coerce')
- ›Outlier detection: IQR method, Z-score, clip()
- ›Standardization: regex-based normalization
- ›Data validation: pandera, great_expectations
- ›Encoding issues: encoding='utf-8-sig'
- ›Production cleaning pipeline with copy()
Visualization Libraries
- ›Matplotlib: foundation, full control, static reports
- ›Seaborn: statistical charts, heatmaps, distribution plots
- ›Plotly: interactive charts for notebooks and web dashboards
- ›Plotly Express: high-level API, one-line charts
- ›Chart selection: trend→line, comparison→bar, distribution→histogram
- ›Best practices: labels, titles, units, consistent colors
Excel & File Automation
- ›openpyxl — read/write Excel with formatting
- ›xlsxwriter — create formatted Excel reports
- ›pandas.ExcelWriter — multi-sheet Excel output
- ›pandas.read_csv with all parameters mastered
- ›glob, os — process multiple files
- ›Batch CSV processing pattern
Git & Version Control
- ›git init, clone, status, add, commit — daily workflow
- ›git branch, checkout, merge — feature branching
- ›git pull, push, fetch — remote repos (GitHub/GitLab)
- ›git log --oneline, git diff — inspect history
- ›git stash — save work in progress
- ›.gitignore — never commit credentials or large files
- ›Conventional commit messages: feat:, fix:, chore:, docs:
- ›nbstripout — strip notebook outputs before commit
Advanced Python Skills for Senior Analysts
Automation, SQL integration, APIs, performance optimization, BI tools, and advanced analytics.
Automation & ETL
- ›Email: smtplib, email.mime — send reports with attachments
- ›Scheduling: schedule library, cron (Linux), Windows Task Scheduler
- ›ETL: Extract → Transform → Load pipeline pattern
- ›Logging: Python logging module — essential for production
- ›Config files: .env, YAML, JSON — never hardcode
- ›Error alerts: try/except + email notification on failure
- ›Production pipeline pattern with logging
SQL + Python Integration
- ›sqlalchemy — database engine, works with all databases
- ›psycopg2 — PostgreSQL native driver
- ›pyodbc — SQL Server connection
- ›pandas.read_sql() — query to DataFrame directly
- ›DataFrame.to_sql() — write results back to DB
- ›Parameterized queries — SQL injection prevention
- ›Connection pooling for repeated queries
- ›Environment variables for credentials
APIs & Web Scraping
- ›requests — HTTP requests, REST APIs
- ›BeautifulSoup4 — HTML parsing
- ›Scrapy — production web scraping
- ›httpx — async HTTP (faster for many requests)
- ›json — parse API responses
- ›pandas.json_normalize() — flatten nested JSON
- ›Pagination pattern for collecting all pages
- ›Rate limiting and exponential backoff
Performance Optimization
- ›Dtype optimization: int32 vs int64, category for strings
- ›Chunked reading: pd.read_csv(chunksize=50000)
- ›Vectorization: replace apply() with numpy/pandas operations
- ›Parquet format: 10× faster than CSV, 5× smaller
- ›Polars library: Rust-based DataFrame, 5–50× faster than Pandas
- ›DuckDB: in-process SQL on DataFrames
- ›numba @jit: JIT-compile Python loops to machine code
BI Integration & Dashboards
- ›Python in Power Query: custom transforms using Python script
- ›Power BI REST API: trigger refresh, manage datasets
- ›Streamlit: build Python-native interactive dashboards in hours
- ›Dash (Plotly): full production dashboard apps
- ›Parquet/Delta files: Python writes → Power BI reads
- ›Streamlit dashboard with KPI cards and interactive filters
Advanced Analytics
- ›Statistical tests: scipy.stats — t-test, chi-square, ANOVA
- ›A/B testing: power analysis, p-value, confidence intervals
- ›Forecasting: Prophet, statsmodels ARIMA, exponential smoothing
- ›Regression: scikit-learn LinearRegression, feature importance
- ›Clustering: K-Means for customer segmentation
- ›Correlation analysis: Pearson, Spearman, Kendall
BigQuery + Python
- ›google-cloud-bigquery — official BQ Python client
- ›pandas-gbq — lightweight BQ ↔ DataFrame bridge
- ›google-cloud-storage — read/write GCS buckets
- ›Cost-aware queries: use dry_run=True first
- ›Partitioned tables: always filter on partition column
- ›Clustering: cluster on high-cardinality columns
- ›pd.read_gbq() — single-line BQ → DataFrame
Jupyter Production Workflows
- ›papermill — execute notebooks with parameters from CLI or Python
- ›nbconvert — convert notebooks to HTML, PDF, Markdown, slides
- ›nbstripout — strip outputs before git commit
- ›Notebook structure: title → imports → parameters → sections → output
- ›Parameters cell: tag one cell as 'parameters' for Papermill
- ›Automated notebook execution over multiple parameters
Automated EDA & Google APIs
- ›ydata-profiling — full EDA report in 2 lines
- ›Minimal mode for large datasets (>500K rows)
- ›Google Sheets API (gspread) — Python to Sheets
- ›Looker/Looker Studio — BQ-native dashboards
- ›Google Workspace APIs — Drive, Sheets automation
- ›Automated data exports to Google Sheets
30-60-90 Day Python Learning Plan
For a working analyst putting in 2–3 hrs/day. Phase 1 in Days 1–60. Phase 2 in Days 61–90 and beyond.
Phase 1 Foundation
Python Fundamentals, Pandas, NumPy, Data Cleaning
Phase 1 Complete
Visualization, Excel Automation, Daily Analyst Tasks
Phase 2 — Advanced
SQL, Automation, APIs, Performance, Advanced Analytics
4-Phase Interview Preparation Roadmap
Expect live coding exercises — practice for speed and accuracy.
Phase 1 — Fundamentals Cold
- ›List vs tuple vs dict vs set — when to use each
- ›loc vs iloc — demonstrate both with examples
- ›GroupBy + agg vs groupBy + transform — business examples
- ›Clean a column with mixed formats to numeric
- ›Write a function with proper type hints and docstring
- ›LeetCode Python — Easy/Medium problems timed
- ›Write Pandas operations without documentation
- ›Explain code out loud as you write it
- ›Practice with real datasets (Kaggle, StrataScratch)
Pandas & Data Manipulation Sprint
- ›Filtering with boolean masks and query()
- ›Merge, join, concat — know all 3 and when to use
- ›Pivot tables and crosstab for business reporting
- ›Date operations: to_datetime, .dt accessor, date arithmetic
- ›Apply vs vectorized operations — performance implications
- ›Explain SettingWithCopyWarning and how to avoid it
- ›Mention memory optimization (dtype downcasting)
- ›Discuss when to use apply() and when not to
- ›Always mention .copy() when working with slices
Phase 2 — Automation & ETL
- ›Design an ETL pipeline with logging and error handling
- ›Parameterized SQL queries in Python (security)
- ›API integration with pagination and rate limiting
- ›Email automation with attachments
- ›Scheduling with schedule library or cron
- ›Show logging in every pipeline
- ›Use .env files for credentials
- ›Write tests for ETL functions
- ›Document with READMEs and docstrings
- ›Version control with clean git commits
Performance & Advanced Analytics
- ›Optimize a 50M row DataFrame (dtypes, chunking, DuckDB)
- ›Build an A/B test analysis function
- ›Create a forecasting model (Prophet or ARIMA)
- ›Build a Streamlit dashboard with interactive filters
- ›Integrate BigQuery with Python (cost-aware queries)
- ›Real project where Python saved significant time
- ›Quantify impact: "4-hour manual task → 30-second script"
- ›Production features: logging, error handling, config files
- ›Testing and code quality practices
- ›Git workflow with feature branches and PRs
Top Python Interview Questions
Common questions asked at data analyst interviews across tech, finance, and consulting.
Python Fundamentals
- What is the GIL in Python and how does it affect multi-threaded data processing?
- What are list comprehensions? Write one to extract emails from a list of strings.
- What is the difference between a shallow copy and a deep copy? When does it matter in Pandas?
- How do decorators work? Write a timing decorator for an analytics function.
- What is the difference between a list and a tuple? When would you use each?
Pandas Core
- What is SettingWithCopyWarning? How do you avoid it?
- What is the difference between merge() and join()? When would you use each?
- How does groupby + transform differ from groupby + agg? Give a business example.
- How would you find and handle outliers in a revenue column? Write the code.
- How do you calculate a 7-day rolling average in Pandas?
- What is pd.cut() and pd.qcut()? When would you use each for analytics?
Data Cleaning
- A column contains '£1,200', '1200.00', 'N/A'. Clean it to float in one pipeline.
- How would you standardize inconsistent date formats across 50,000 rows?
- What is the difference between fillna(method='ffill') and fillna(value=0)?
Automation & Production
- Design a Python script that reads SQL, creates a report, and emails it every Monday.
- How do you prevent hardcoded credentials in Python scripts?
- What logging best practices do you follow for production analytics scripts?
- How do you handle an API that returns paginated results?
Performance
- A Pandas apply() on 10M rows takes 45 minutes. How do you fix it?
- How do you process a 5GB CSV that doesn't fit in RAM?
- When would you use Polars instead of Pandas?
Analytics & Statistics
- What is p-value? In an A/B test, p=0.04 with 10 variants. Is the result significant?
- How do you calculate customer lifetime value in Python from a transaction dataset?
- What is the difference between correlation and causation? Give a real analytics example.
- Write a Python function to calculate month-over-month revenue growth for each product.
Hands-On Projects & Portfolio Ideas
Build these to prove real-world Python mastery. Each covers multiple topic areas.
Sales Analysis Pipeline — E-Commerce Dataset
Read CSV, clean data (duplicates, nulls, outliers), calculate KPIs (revenue, AOV, MoM growth), create 5 visualizations, output formatted Excel report.
Automated EDA Report Generator
Build a DataProfiler class that accepts any DataFrame and outputs HTML EDA report: data profiling, correlation heatmap, outlier detection, and business commentary.
Automated Weekly Business Report System
ETL pipeline: connect to SQL, run queries, transform with Pandas, create Plotly charts, format Excel with openpyxl, email to stakeholders at 7am every Monday.
Customer Churn Analysis + A/B Test Framework
RFM segmentation, cohort retention heatmap, churn prediction with logistic regression, A/B test analysis, Streamlit dashboard with interactive filters.
Supply Chain Demand Forecasting
Pull historical sales via API, enrich with external APIs, train Prophet/ARIMA model, build Streamlit dashboard with actuals vs forecast and confidence intervals.
Business Scenarios You'll Actually Face
Common asks from actual analyst roles. Know how to solve each end-to-end.
📊Scenario 1 — 'Our weekly report takes 4 hours manually — automate it'
- ›Download CSVs from 5 systems
- ›Manual copy-paste into Excel
- ›Create pivot tables
- ›Format charts and KPIs
- ›Email to 20 stakeholders
- ›Write a pandas script to combine sources
- ›Power Query style cleaning pipeline
- ›Automate pivot tables with groupby
- ›Plotly charts with consistent branding
- ›smtplib email with attachments
- ›4-hour manual → 30-second script
- ›Zero copy-paste errors
- ›Audit trail with logging
- ›Stakeholder confidence in data quality
- ›Free time for deeper analytics
🗄Scenario 2 — 'Query a database and build a dashboard for stakeholders'
- ›Stakeholders need daily KPI visibility
- ›Data lives in SQL database
- ›Dashboards must be interactive
- ›No budget for Power BI licenses
- ›SQLAlchemy to connect and query
- ›Pandas for transformation
- ›Streamlit for interactive dashboard
- ›Deploy on Streamlit Cloud for free
- ›Interactive dashboard with filters
- ›KPI cards with metrics
- ›Trend charts with date range
- ›CSV download for stakeholders
🌐Scenario 3 — 'Pull data from an external API for competitive intelligence'
- ›Pull competitor pricing data daily
- ›API has rate limits (100/min)
- ›Need historical trend analysis
- ›Alert when price changes >10%
- ›requests with exponential backoff
- ›Pagination for all pages
- ›Store in Parquet for efficiency
- ›Schedule with cron job
- ›Daily competitor price snapshot
- ›Trend analysis with Plotly
- ›Automated price change alerts
- ›Clean data ready for analysis
⚡Scenario 4 — 'Our 50M row Python script crashes with MemoryError'
- ›Dataset is 5GB CSV
- ›Pandas loads entire file into RAM
- ›Apply operations are slow
- ›Script runs out of memory
- ›Use dtype downcasting (30-50% memory reduction)
- ›Process in chunks with pd.read_csv(chunksize=)
- ›Switch to Polars or DuckDB for 10× speedup
- ›Save intermediate as Parquet
- ›Script runs on 4GB RAM
- ›Processing time: 45min → 5min
- ›No more memory errors
- ›Pattern reusable for other datasets
Python Best Practices Used at Companies
Standards followed by professional analysts at product companies, consulting firms, and data-driven enterprises.
Code Organization
- ›One function = one responsibility
- ›Separate concerns: extract.py, transform.py, load.py
- ›Config files (YAML/JSON) for all parameters
- ›requirements.txt + virtual environment for every project
- ›Follow PEP8: use flake8 or black formatter
- ›Docstrings on every function: purpose, params, returns
- ›Type hints everywhere
Security & Reliability
- ›Never hardcode credentials — use python-dotenv + .env
- ›Always use parameterized SQL — never string concatenation
- ›Validate all inputs before processing
- ›Log every pipeline step with timestamps and row counts
- ›Test data quality assertions before downstream use
Performance Standards
- ›Profile before optimizing — use %timeit and memory_profiler
- ›Avoid apply() — use vectorized operations always
- ›Set correct dtypes at read time — saves 50-70% memory
- ›Use Parquet over CSV for intermediate files
- ›Process in chunks for > 1M rows
- ›Use DuckDB for complex SQL-like aggregations
Testing & Documentation
- ›Write pytest tests for every transformation function
- ›Test with edge cases: empty DataFrame, all-null column
- ›README in every project: setup, usage, data sources
- ›Jupyter Notebooks: use markdown to explain decisions
- ›Version control: commit after every working feature
Anti-Patterns to Avoid
- ›Chained assignment: df['a']['b'] = 1 — use .loc always
- ›Iterating rows with iterrows() — use vectorized alternatives
- ›apply() with a lambda that could be vectorized
- ›Reading entire files when only specific columns needed
- ›No error handling in production scripts
- ›Magic numbers everywhere — define as named constants
Data Standards
- ›Always validate row counts before/after merge
- ›Log 'before' and 'after' counts for every cleaning step
- ›Save intermediate checkpoints to Parquet
- ›Never overwrite source files
- ›Use UTC timestamps internally
- ›Store raw, clean, and aggregated data at different stages