# Muse Arbitrage Lead Cleaner CLI

## PURPOSE
A MetaMuse mining run dumps a CSV of service providers ("night nurses at $30 an hour in Montreal") pulled from public Facebook groups, Marketplace and Instagram. Before that list is worth anything you must clean it: strip duplicates, normalize names and cities, fill missing prices, and rank by trust. This Click + Pandas CLI takes a raw Muse export and produces a priced, deduplicated, scored CSV you can drop straight into Airtable or Google Sheets.

## WHY THIS MATTERS
The video's thesis is information arbitrage: Meta cannibalizes Facebook groups, Marketplace and Instagram so you can mine them, but the value sits in the cleaning step — "think of this as like dirty data... Muse is going to actually do the cleaning of the data." This tool reproduces that cleaning deterministically, so students see exactly what "owning the list" costs and produces.

## HOW TO BUILD
1. Read the raw export with `pandas.read_csv`.
2. Normalize `name` (title case, collapse whitespace) and `city`.
3. Drop duplicates on `(name, city)`, keeping the highest-trust row.
4. Fill `hourly_rate` with the niche median, then the $30 default.
5. Group by `niche`/`city` and report the success-fee margin vs the old agency.

```python
@click.command()
@click.argument("raw_csv", type=click.Path(exists=True))
@click.option("--out", default="clean_leads.csv")
def clean(raw_csv, out):
    df = pd.read_csv(raw_csv)
    df["name"] = df["name"].str.strip().str.title()
    df = df.drop_duplicates(subset=["name", "city"], keep="first")
    df["hourly_rate"] = df["hourly_rate"].fillna(df["hourly_rate"].median())
    df.to_csv(out, index=False)
    click.echo(f"wrote {len(df)} cleaned leads -> {out}")
```

## WHEN TO USE IN PRODUCTION
Use it every time a new niche or city is onboarded: night nurses in Tampa, furniture in Austin, plumbers in Phoenix. It is the batch step before loading a lead list into your CRM. Do NOT use it as a live crawler — MetaMuse does the mining and this only cleans its output — and skip it for one-off lists under a few dozen rows.

## HOW IT HELPS STUDENTS
Students learn real Pandas data-cleaning workflows plus Click CLI ergonomics, and walk away with a reusable pipeline they can point at any mined Marketplace or Instagram export.

## STARTER CODE
`starter/main.py` defines `clean`, `score` and `margin` commands, a deterministic `trust_score` stub, and `# TODO` markers for a real Muse cleaning call and an Airtable push.
