Skip to content

Commit b9fe056

Browse files
committed
bug fixes
1 parent c7e1a7c commit b9fe056

6 files changed

Lines changed: 39 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ One import, one line. A clean, sorted DataFrame you can read or feed into the ne
5555

5656
| Function | What it answers |
5757
|---|---|
58-
| `profile` | What is wrong with this dataset, and how do I fix it? |
58+
| `profiler` | What is wrong with this dataset, and how do I fix it? |
5959
| `change` | Growth as numbers, columns, or a whole series |
6060
| `vif` | Which features are collinear? |
6161
| `missing` | How much of each column is missing? |

docs/documentation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ polars stays optional: it is only imported when you actually pass a polars objec
4545

4646
---
4747

48-
## `profile`
48+
## `profiler`
4949

5050
The flagship: a one-call **data diagnostician**. Instead of dumping statistics for every column, it runs a battery of checks, ranks the problems worst-first, scores the data's health, and tells you how to fix each issue. It composes the rest of the toolkit (`missing`, `imbalance`, and more) under one entry point.
5151

@@ -55,14 +55,14 @@ The flagship: a one-call **data diagnostician**. Instead of dumping statistics f
5555
**Signature**
5656

5757
```python
58-
profile(data, target=None)
58+
profiler(data, target=None)
5959
```
6060

6161
**Example**
6262

6363
```python
6464
import pandas as pd
65-
from percentify import profile
65+
from percentify import profiler
6666

6767
df = pd.DataFrame({
6868
"user_id": range(100), # identifier
@@ -72,7 +72,7 @@ df = pd.DataFrame({
7272
"churn": ["No"] * 96 + ["Yes"] * 4, # imbalanced target
7373
})
7474

75-
report = profile(df, target="churn")
75+
report = profiler(df, target="churn")
7676
report.health # 87
7777
report.to_frame()
7878
```

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ One import, one line. A clean, sorted DataFrame you can read or feed straight in
5454

5555
| Function | What it answers |
5656
|---|---|
57-
| `profile` | What is wrong with this dataset, and how do I fix it? |
57+
| `profiler` | What is wrong with this dataset, and how do I fix it? |
5858
| `change` | How much did a value grow, across numbers, columns, or a whole series? |
5959
| `vif` | Which features are collinear? |
6060
| `missing` | How much of each column is missing? |

percentify/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from .profiling import profile, ProfileReport, Finding
1+
from .profiling import profiler, ProfileReport, Finding
22
from .stats import (
33
change, vif, missing, cv, outliers, r_squared, pca_variance, imbalance,
44
difference, split, display, PercentifyWarning,
55
)
66

77
__all__ = [
8-
"profile", "ProfileReport", "Finding",
8+
"profiler", "ProfileReport", "Finding",
99
"change", "vif", "missing", "cv", "outliers", "r_squared", "pca_variance", "imbalance",
1010
"difference", "split", "display", "PercentifyWarning",
1111
]

percentify/profiling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Diagnostic profiling for Percentify.
22
3-
Unlike descriptive profilers that dump statistics for every column, ``profile``
3+
Unlike descriptive profilers that dump statistics for every column, ``profiler``
44
is a *diagnostician*: it runs a registry of checks, surfaces the problems that
55
actually matter, ranks them worst-first, and tells you how to fix each one.
66
7-
from percentify import profile
7+
from percentify import profiler
88
9-
report = profile(df) # pandas or polars in, report out
9+
report = profiler(df) # pandas or polars in, report out
1010
report # pretty summary (repr / notebook HTML)
1111
report.errors # just the blocking issues
1212
assert not report.errors # drop straight into CI
@@ -37,7 +37,7 @@
3737

3838
from .stats import PercentifyWarning, imbalance, missing
3939

40-
__all__ = ["profile", "ProfileReport", "Finding"]
40+
__all__ = ["profiler", "ProfileReport", "Finding"]
4141

4242
# Severity ordering and the penalty each level deducts from the health score.
4343
_SEVERITY_ORDER = {"error": 0, "warning": 1, "info": 2}
@@ -380,7 +380,7 @@ def check_target_imbalance(df: pd.DataFrame, target) -> list[Finding]:
380380
# --------------------------------------------------------------------------- #
381381
@dataclass
382382
class ProfileReport:
383-
"""The result of :func:`profile`. Also a plain object you can act on."""
383+
"""The result of :func:`profiler`. Also a plain object you can act on."""
384384

385385
n_rows: int
386386
n_cols: int
@@ -487,7 +487,7 @@ def _repr_html_(self) -> str:
487487
# --------------------------------------------------------------------------- #
488488
# Public entry point
489489
# --------------------------------------------------------------------------- #
490-
def profile(data, target: Optional[str] = None) -> ProfileReport:
490+
def profiler(data, target: Optional[str] = None) -> ProfileReport:
491491
"""Diagnose a DataFrame: rank its problems worst-first, with fixes.
492492
493493
Parameters

tests/test_profiling.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
import numpy as np
33
import pandas as pd
4-
from percentify import profile, ProfileReport, Finding, PercentifyWarning
4+
from percentify import profiler, ProfileReport, Finding, PercentifyWarning
55

66

77
@pytest.fixture
@@ -18,72 +18,72 @@ def messy_df():
1818
})
1919

2020

21-
def test_profile_returns_report(messy_df):
22-
assert isinstance(profile(messy_df), ProfileReport)
21+
def test_profiler_returns_report(messy_df):
22+
assert isinstance(profiler(messy_df), ProfileReport)
2323

2424

25-
def test_profile_all_missing_is_error(messy_df):
26-
codes = {(f.column, f.code) for f in profile(messy_df).errors}
25+
def test_profiler_all_missing_is_error(messy_df):
26+
codes = {(f.column, f.code) for f in profiler(messy_df).errors}
2727
assert ("empty", "all_missing") in codes
2828

2929

30-
def test_profile_flags_constant_and_id(messy_df):
31-
warn_codes = {f.code for f in profile(messy_df).warnings}
30+
def test_profiler_flags_constant_and_id(messy_df):
31+
warn_codes = {f.code for f in profiler(messy_df).warnings}
3232
assert "constant" in warn_codes
3333
assert "id_like" in warn_codes
3434
assert "collinear" in warn_codes
3535

3636

37-
def test_profile_target_imbalance(messy_df):
38-
infos = {f.code for f in profile(messy_df, target="churn").infos}
37+
def test_profiler_target_imbalance(messy_df):
38+
infos = {f.code for f in profiler(messy_df, target="churn").infos}
3939
assert "imbalance" in infos
4040

4141

42-
def test_profile_to_frame(messy_df):
43-
frame = profile(messy_df).to_frame()
42+
def test_profiler_to_frame(messy_df):
43+
frame = profiler(messy_df).to_frame()
4444
assert isinstance(frame, pd.DataFrame)
4545
assert list(frame.columns) == ["severity", "code", "column", "message", "suggestion"]
4646

4747

48-
def test_profile_findings_are_findings(messy_df):
49-
assert all(isinstance(f, Finding) for f in profile(messy_df).findings)
48+
def test_profiler_findings_are_findings(messy_df):
49+
assert all(isinstance(f, Finding) for f in profiler(messy_df).findings)
5050

5151

52-
def test_profile_clean_data_full_health():
52+
def test_profiler_clean_data_full_health():
5353
clean = pd.DataFrame({
5454
"a": [x % 10 for x in range(30)],
5555
"b": [x % 7 for x in range(30)],
5656
})
57-
report = profile(clean)
57+
report = profiler(clean)
5858
assert report.findings == []
5959
assert report.health == 100
6060

6161

62-
def test_profile_health_drops_with_issues(messy_df):
63-
assert profile(messy_df).health < 100
62+
def test_profiler_health_drops_with_issues(messy_df):
63+
assert profiler(messy_df).health < 100
6464

6565

66-
def test_profile_target_not_found_warns(messy_df):
66+
def test_profiler_target_not_found_warns(messy_df):
6767
with pytest.warns(PercentifyWarning):
68-
profile(messy_df, target="does_not_exist")
68+
profiler(messy_df, target="does_not_exist")
6969

7070

71-
def test_profile_html_escapes_column_names():
71+
def test_profiler_html_escapes_column_names():
7272
evil = pd.DataFrame({"<script>": [None] * 200, "ok": range(200)})
73-
rendered = profile(evil)._repr_html_()
73+
rendered = profiler(evil)._repr_html_()
7474
assert "&lt;script&gt;" in rendered
7575
assert "<script>" not in rendered
7676

7777

78-
def test_profile_composes_missing_high_warning():
78+
def test_profiler_composes_missing_high_warning():
7979
# 60% missing should surface as a high_missing warning (via missing()).
8080
df = pd.DataFrame({"col": [1.0, 2.0] + [None] * 3})
81-
codes = {f.code for f in profile(df).warnings}
81+
codes = {f.code for f in profiler(df).warnings}
8282
assert "high_missing" in codes
8383

8484

85-
def test_profile_polars_input(messy_df):
85+
def test_profiler_polars_input(messy_df):
8686
pl = pytest.importorskip("polars")
87-
report = profile(pl.from_pandas(messy_df), target="churn")
87+
report = profiler(pl.from_pandas(messy_df), target="churn")
8888
assert isinstance(report, ProfileReport)
8989
assert any(f.code == "all_missing" for f in report.errors)

0 commit comments

Comments
 (0)