carrotcake
Automatic data quality reports, cleaning, and EDA reports for messy pandas DataFrames.
Every real dataset has the same handful of problems: inconsistent category
spellings ("Low Fat" vs "low fat" vs "LOW FAT"), missing values, zeros
that actually mean "missing," statistical outliers, messy column names, and
duplicate rows. carrotcake finds and fixes all of it, and generates a full
HTML exploratory data analysis report, in a handful of function calls.
Install
pip install carrotcake
Depends on pandas, numpy, and matplotlib (needed for eda_report's charts).
Quick start
import pandas as pd
from carrotcake import quality_report, autoclean
df = pd.read_csv("sales.csv")
print(quality_report(df))
# carrotcake quality report — 8523 rows x 12 columns
# [missing] Item_Weight: 5.2% missing
# [inconsistent_categories] Item_Fat_Content: 3 variants: ['LF', 'Low Fat', 'low fat']
# [zero_as_missing] Item_Visibility: 8.1% zero values
# [outliers] Item_MRP: 1.8% of values are statistical outliers
# [duplicates] <rows>: 3 duplicate rows
df_clean = autoclean(df, group_by="Item_Type")
autoclean will:
- Standardize inconsistent categorical spellings to their most frequent original form
- Treat suspiciously frequent zeros in numeric columns as missing values
- Impute missing values (group mean/mode when
group_byis given, falling back to the overall column median/mode) - Drop exact duplicate rows (run last, since standardizing values above can turn near-duplicate rows into exact duplicates)
Two more steps are available but off by default, since they're stronger, more opinionated transformations:
autoclean(df, clean_column_names=True, handle_outliers=True)
clean_column_names— standardizes messy headers like"Item Weight "or"Sales($)"intoitem_weight,saleshandle_outliers— clips statistical outliers (IQR method) to the nearest acceptable bound
Every step can be disabled individually:
autoclean(df, fix_categories=False, fix_zero_as_missing=False)
EDA reports
from carrotcake import eda_report
eda_report(df, output="report.html")
Generates a self-contained HTML report: dataset summary, missing-value table, per-column stats, a histogram for every numeric column, a correlation heatmap, and bar charts of the most common values per categorical column. Opens in any browser, no server needed.
Auditing what changed
from carrotcake import compare
print(compare(df, df_clean))
# carrotcake compare — 8523 -> 8519 rows (4 dropped)
# [missing_fixed] Item_Weight: 443 -> 0 missing values
# [categories_standardized] Item_Fat_Content: 5 -> 2 unique values
# [zero_fixed] Item_Visibility: 526 -> 0 zero values
Compares aggregate column-level statistics rather than diffing individual cells, so it stays meaningful even after row dropping/reordering.
Programmatic use
report = quality_report(df)
report.to_dict() # plain dict
report.to_json() # JSON string, e.g. for a CI data-quality gate
Command line
carrotcake report sales.csv
carrotcake report sales.csv --json
carrotcake clean sales.csv -o sales_clean.csv --group-by Item_Type --handle-outliers
carrotcake eda sales.csv -o report.html
Why
Built after hand-writing this exact cleaning logic across multiple data
analysis projects (retail sales, hotel bookings). carrotcake packages it up
so it doesn't need to be rewritten for every new dataset.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file carrotcake-0.2.0.tar.gz.
File metadata
- Download URL: carrotcake-0.2.0.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
111af3bb498181fb652fb72bf13731b56fa06ab287c1bc0a26b36fccccbd9235
|
|
| MD5 |
298b9d5051c4bfbe4e8832089fbfe17d
|
|
| BLAKE2b-256 |
0075bcb5625a21162df082982827b15805797dc04b0f9fbe4b6b01a998bedc69
|
File details
Details for the file carrotcake-0.2.0-py3-none-any.whl.
File metadata
- Download URL: carrotcake-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0347b3ee6b0bf0f7570c96cab3db1fdb1c0a247a05d0c888bff1075373572e2
|
|
| MD5 |
dfdeeae94a7d3b2a5f81e0e4e9446968
|
|
| BLAKE2b-256 |
9b721c483726383b9469a2c21a443963df4322a8bcd0bea9c0543592a71619fe
|