Skip to content

commandData and AIpythonpandas

Profile DataFrame

Profiles a pandas DataFrame for dtypes, nulls, outliers and duplicates, then suggests exact pandas fixes for each issue.

npx workspacetemplates add profile-dataframe --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/profile-dataframe.md15 lines · 1.2 KBFile
---
description: Profiles a pandas DataFrame for dtypes, nulls, outliers and duplicates, then suggests exact pandas fixes for each issue.
argument-hint: "[variable name, file or loader function]"
---

Profile the pandas DataFrame: $ARGUMENTS (a variable, a file that builds it, or a file to load).

1. Find where the frame is created. Write a small script or use the notebook to load it without altering the source. Never modify the original frame; work on `df.copy()`.
2. Print `df.shape`, `df.dtypes`, `df.memory_usage(deep=True)` and `df.isna().mean()` sorted high to low.
3. For object columns, check for numbers or dates stored as strings, mixed case, leading and trailing whitespace, and low cardinality that should be `category`.
4. For numeric columns, find outliers by the 1.5 IQR rule and impossible values. Show `df.describe()`.
5. Count `df.duplicated().sum()`, and also duplicates on the likely key columns.
6. Check index uniqueness and sort order, and datetime columns for time zone and gaps.

Report a table: column, issue, evidence, and a one-line fix such as `df["price"] = pd.to_numeric(df["price"].str.replace("$",""))`. Ask whether to apply fixes into a cleaning function.

What it does

Bad dtypes and hidden duplicates cause quiet errors in joins and averages. This command inspects a DataFrame already in your code or notebook and tells you what is wrong with each column.

Every finding comes with a one-line pandas fix you can paste. It only reads the data, so the original frame stays unchanged until you decide.

Example

you › /profile-dataframe orders from etl/load.py

agent › orders: 120,400 x 11, 38 MB.
signup_date is object (parse with pd.to_datetime), status has 9 values for 4 real ones (case and spaces), 214 duplicate order_id rows, total has 3 negative values.
Fixes listed per column. Write them into clean_orders()?

Questions

Does it modify my DataFrame?
No. It works on a copy and only suggests fixes until you approve a cleaning function.
Can it handle big frames?
For very large data it profiles a random sample and says so in the report.
  • Analyze CSV

    Commandpython

    Free
  • Clean Notebook

    Commandpython

    Free
  • Eval Prompt

    CommandData and AI

    Free
  • SQL From Question

    CommandData and AI

    Free