Metadata-Version: 2.4
Name: carrotcake
Version: 0.2.0
Summary: Automatic data quality reports, cleaning, and EDA reports for messy pandas DataFrames
Author-email: Aaryan Koradia <aaryanhkoradia@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/AaryanKoradia/carrotcake
Project-URL: Repository, https://github.com/AaryanKoradia/carrotcake
Keywords: pandas,data-cleaning,data-quality,eda,data-science
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.5
Requires-Dist: numpy>=1.23
Dynamic: license-file

# 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

```bash
pip install carrotcake
```

Depends on pandas, numpy, and matplotlib (needed for `eda_report`'s charts).

## Quick start

```python
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_by` is 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:

```python
autoclean(df, clean_column_names=True, handle_outliers=True)
```

- `clean_column_names` — standardizes messy headers like `"Item Weight "` or
  `"Sales($)"` into `item_weight`, `sales`
- `handle_outliers` — clips statistical outliers (IQR method) to the nearest
  acceptable bound

Every step can be disabled individually:

```python
autoclean(df, fix_categories=False, fix_zero_as_missing=False)
```

## EDA reports

```python
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

```python
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

```python
report = quality_report(df)
report.to_dict()   # plain dict
report.to_json()   # JSON string, e.g. for a CI data-quality gate
```

## Command line

```bash
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
