Pandas Fundamentals: 40 Questions to Go From List to DataFrame
Pandas fundamentals in 40 questions — Series, DataFrame, head, dtypes, loc vs iloc, filtering, sorting, and null handling.
Forty questions, one skill ladder — Series -> DataFrame -> inspect -> filter -> sort -> handle nulls -> group — so your muscle memory survives a live interview.
What does the 40-question ladder build?
Part 1 Series/DataFrame -> head/shape/dtypes -> iloc/loc -> filtering & string ops -> sorting -> missing -> groupby -> merging, each mapped to a YouTube reference (Series Basics, Filtering & Sorting, loc vs iloc). Pair with the Cheatsheet for desk reference and the Advanced masterclass after you finish.
Ingredients: 40 prompts from a starter DataFrame (Name, Age, City) expanding to salary and department extensions.
How do you create and inspect a DataFrame?
Setup:
import pandas as pd
import numpy as np# Q1-Q2: Series vs DataFrame
s = pd.Series([10,20,30,40], index=['a','b','c','d'])
print(s)
df = pd.DataFrame({'Name':['Alice','Bob','Charlie'], 'Age':[25,30,35], 'City':['NY','LA','SF']})
print(df)
# Q3-Q6: Inspect
print(df.head(2))
print(df.shape) # (3, 3)
print(df.columns.tolist())
print(df.dtypes)
print(df.info())
print(df.describe())Rendered output: s shows labeled index a->d; df three rows with Name object, Age int64. The info/describe block mirrors your EDA opening per EDA playbook.
How do you select, filter, and sort?
# loc vs iloc
print(df.loc[0, 'City']) # SF via label
print(df.iloc[0, 2]) # SF via position — same cell, different path
# Filtering — pay attention to parentheses and &
print(df[df['Age']>26])
print(df[(df['Age']>26) & (df['City']=='NY')])
# Strings
print(df[df['Name'].str.contains('li', case=False)])
print(df[df['Name'].str.startswith('A')])
# Sorting
print(df.sort_values('Age', ascending=False))
print(df.sort_values(['City','Age'], ascending=[True, False]))Rendered output: str.contains('li') matches Alice; startswith A isolates her as well — handy for prefix scans like email domains.
How do you handle missing data and group?
# Inject a NaN to demonstrate
df2 = df.copy()
df2.loc[1, 'Age'] = np.nan
print(df2.isna().sum())
print(df2.dropna())
print(df2['Age'].fillna(df2['Age'].median()))
# Groupby — team equivalent in master workbook
data = {'Team':['Red','Red','Blue','Blue'], 'Points':[10,15,20,25]}
dfg = pd.DataFrame(data)
print(dfg.groupby('Team')['Points'].mean())
print(dfg.groupby('Team').agg(avg=('Points','mean'), cnt=('Points','count')))| Feature / Criteria |
|---|
Gotcha: loc vs iloc Mixup on a Non-Range Index
When the index is not 0,1,2 (e.g., employee IDs 101...), df.loc[0] raises KeyError while df.iloc[0] still returns the first row — they are not interchangeable. Check df.index before choosing.
How do you continue?
Re-run every drill on the evolving frame until each answer is one line from memory. Then take the 50Q Master Workbook for grouped aggregation reps and wire the workflow into your Excel pivot dashboard for stakeholder delivery.
Download the Notebook and Practise
This article is a walkthrough of a runnable Jupyter notebook. Download the original .ipynb and run it locally or on Colab — every code block above appears in order.
Download the Pandas Fundamentals Notebook
Get the complete .ipynb with outputs — runs on any Python 3.10+ environment with pandas, numpy, and the libraries listed in setup.
Download .ipynbContinue your track: Data Analyst Roadmap · Python and Pandas Guide · SQL NULL Handbook · SQL JOIN Fan-Out · Topfolio Practice · Data Analyst vs Engineer
Dataset generators where applicable are in courses/workbooks/generators/ — see citations atop for the exact *.py source for this notebook.
Frequently Asked Questions
What is the difference between Series and DataFrame?
Series is one column (1-D with an index); DataFrame is a table of many Series (2-D). df['Age'] returns a Series; df[['Age']] returns a DataFrame.
When do you use loc vs iloc?
loc is label-based (df.loc[0, 'City'] by index label), iloc is position-based (df.iloc[0, 2] by integer position). Mixups cause silent wrong-row bugs.
How do you read a CSV safely?
pd.read_csv('file.csv', dtype={'id': str}, parse_dates=['date'], na_values=['', 'NA']). Specify dtypes to avoid silent int->float coercion.
What does df.describe() actually compute?
Count, mean, std, min, 25%, 50%, 75%, max for numeric columns — a one-line equivalent of five SQL aggregates.
Frequently Asked Questions
What is the difference between Series and DataFrame?
Series is one column (1-D with an index); DataFrame is a table of many Series (2-D). df['Age'] returns a Series; df[['Age']] returns a DataFrame.
When do you use loc vs iloc?
loc is label-based (df.loc[0, 'City'] by index label), iloc is position-based (df.iloc[0, 2] by integer position). Mixups cause silent wrong-row bugs.
How do you read a CSV safely?
pd.read_csv('file.csv', dtype={'id': str}, parse_dates=['date'], na_values=['', 'NA']). Specify dtypes to avoid silent int->float coercion.
What does df.describe() actually compute?
Count, mean, std, min, 25%, 50%, 75%, max for numeric columns — a one-line equivalent of five SQL aggregates.

Written by
Founder at Topfolio with 6+ years in data & analytics across JPMC, Ultrahuman, and high-growth startups. Sat on hiring panels, reviewed 500+ resumes, and writes practical SQL & data guides.
Related Articles
Python for Data Analysis: The Complete Workflow Playbook (2026)
Master python data analysis with this complete playbook: pandas wrangling, exploratory data analysis, statistical cohorts, and production data pipelines.
Python Tutorial: The Complete Guide for Data Analysts (2026)
Master Python programming with this comprehensive python tutorial for data analysts: variables, data structures, control flow, functions, NumPy, Pandas, and real-world projects.
Python Pandas for Data Analysis: Getting Started Guide (2026)
Learn Python Pandas for data analysis from scratch. DataFrames, filtering, groupby, merging, data cleaning, and 5 one-liners every data analyst should know.