100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Data Wrangling with Pandas Cheat Sheet

Data Wrangling with Pandas Cheat Sheet

Core pandas workflows for reading, cleaning, filtering, handling missing values, and merging datasets during everyday data preparation tasks.

2 PagesBeginnerMar 8, 2026

Reading & Inspecting Data

Load a dataset and get an overview before cleaning it.

python
import pandas as pddf = pd.read_csv("data.csv")df.head()df.info()df.describe()df.dtypesdf.shape# Rename and drop columnsdf = df.rename(columns={"old_name": "new_name"})df = df.drop(columns=["unused_col"])# Filter rowsdf_filtered = df[df["amount"] > 100]df_filtered = df.query("amount > 100 and region == 'US'")

Handling Missing & Duplicate Data

Detect, fill, or drop nulls and remove duplicate rows.

python
df.isna().sum()                     # count nulls per columndf.dropna(subset=["customer_id"])   # drop rows missing a key fielddf["amount"] = df["amount"].fillna(0)df["category"] = df["category"].fillna("Unknown")df["amount"] = df["amount"].fillna(df["amount"].median())df = df.drop_duplicates(subset=["order_id"], keep="first")# Type conversiondf["order_date"] = pd.to_datetime(df["order_date"], errors="coerce")df["amount"] = pd.to_numeric(df["amount"], errors="coerce")

Merging & Transforming

Combine tables and derive new columns.

python
merged = pd.merge(orders, customers, on="customer_id", how="left")combined = pd.concat([df_2023, df_2024], axis=0, ignore_index=True)# apply / map for row-wise transformationsdf["amount_category"] = df["amount"].apply(lambda x: "high" if x > 1000 else "low")df["region_code"] = df["region"].map({"US": 1, "EU": 2, "APAC": 3})

Key Concepts

Ideas that come up in almost every wrangling task.

  • df.info()- Shows column dtypes, non-null counts, and memory usage at a glance
  • NaN vs None- Pandas represents missing numeric data as NaN (float); use isna()/notna() to test, not ==
  • how='left'/'inner'/'outer'- Controls which rows survive a merge based on matches in the join key
  • apply vs vectorized ops- Vectorized operations (df['a'] + df['b']) are much faster than .apply() with a Python function
  • loc vs iloc- .loc selects by label, .iloc selects by integer position
Pro Tip

Avoid looping over rows with iterrows() for transformations - it's orders of magnitude slower than a vectorized operation or .apply() on a Series for anything beyond a few thousand rows.

Was this cheat sheet helpful?

Explore Topics

#DataWranglingWithPandas#DataWranglingWithPandasCheatSheet#DataScience#Beginner#ReadingInspectingData#Handling#Missing#Duplicate#MachineLearning#Git#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet