MohitDecodes
Back to blogsData

Data Cleaning Checklist in Python & Pandas Before Building Any Chart

October 2, 2026 · 6 min read

Analysts spend most of their time cleaning messy exports — inconsistent date formats, trailing whitespace, duplicate order IDs, and numbers stored as strings. Skipping cleanup guarantees wrong averages and broken joins.

The 6-step Pandas sanity check

  • 1. Inspect `df.info()` and `df.isna().sum()` to catch wrong dtypes and missing columns.
  • 2. Parse dates explicitly with `pd.to_datetime(..., errors='coerce')`.
  • 3. Strip whitespace and normalize case (`str.strip().str.lower()`) before grouping.
  • 4. Check duplicates on primary keys (`df.duplicated(subset=['order_id']).sum()`).
  • 5. Decide intentionally whether nulls mean `0`, `'Unknown'`, or should be dropped.
  • 6. Validate outliers (`df.describe()`) — negative prices or year-1900 birthdates show up often.
df["order_date"] = pd.to_datetime(df["order_date"], errors="coerce")
df["city"] = df["city"].str.strip().str.title()
df = df.drop_duplicates(subset=["order_id"])

Further reading