Metadata-Version: 2.5
Name: growthcleanpy
Version: 0.1.0
Summary: Pediatric growth data cleaning (pandas engine)
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: numpy<3,>=2.0
Requires-Dist: pandas<4,>=3.0
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# GrowthCleanPy

GrowthCleanPy is a Python package for cleaning pediatric growth data. It identifies implausible height and weight measurements — such as unit errors, swapped height/weight values, duplicates, carried-forward values, and extreme outliers — by comparing each measurement against standard growth references (WHO, CDC, NHANES, and Tanner height-velocity data). It adds an `exclude` column marking the status of each measurement so that only trustworthy values are retained for analysis.

GrowthCleanPy is a Python port of the R [`growthcleanr`](https://github.com/carriedaymont/growthcleanr) algorithm. This is a **version 0 (minimum viable)** release providing the core pediatric cleaning capability; future releases are expected to add functionality and enhancements.

The growth reference data is bundled with the package — no external data files need to be downloaded or configured.

---

## Installation

GrowthCleanPy requires **Python 3.10 or newer**.

Install from the distributed wheel:

```bash
pip install growthcleanpy-0.1.0-py3-none-any.whl
```

Dependencies (`pandas`, `numpy`) are installed automatically. The same wheel works on Windows, macOS, Linux, and Databricks.

Confirm the installation:

```bash
python -c "import growthcleanpy; print(growthcleanpy.__version__)"
```

---

## Input data

The input is a pandas DataFrame (or CSV) in long format with one measurement per row and the following columns:

| Column | Description |
|---|---|
| `subjid` | Subject / patient identifier |
| `param` | Measurement type (e.g. `HEIGHTCM`, `WEIGHTKG`) |
| `agedays` | Age in days at time of measurement |
| `sex` | Sex (`0`/`1` or `M`/`F`) |
| `measurement` | The measured value (cm or kg) |

---

## Usage

```python
import pandas as pd
from growthcleanpy import cleangrowth

# load your data
df = pd.read_csv("my_growth_data.csv")

# run the cleaner
result = cleangrowth(df)

# review what was flagged
print(result["exclude"].value_counts())

# keep only valid measurements
clean = result[result["exclude"] == "Include"]

# save results
result.to_csv("cleaned_results.csv", index=False)
```

The result is the input data with an added `exclude` column. Rows marked `Include` passed all checks; other labels indicate why a measurement was flagged.

### Common exclude labels

| Label | Meaning |
|---|---|
| `Include` | Passed all checks — keep. |
| `Missing` | Value missing or invalid age. |
| `Exclude-Carried-Forward` | Repeated (carried-forward) value. |
| `Exclude-Extraneous-Same-Day` | Extra measurement on a day with multiple values. |
| `Unit-Error-High` / `Unit-Error-Low` | Likely wrong units (e.g. lbs vs kg). |
| `Swapped-Measurements` | Height and weight appear swapped. |
| `Exclude-SD-Cutoff` | Extreme value beyond the plausibility cutoff. |
| `Exclude-EWMA-*`, `Exclude-*-Height-Change`, `Exclude-Pair-Delta-*` | Flagged by outlier / growth-velocity checks. |

---

## Repository contents

| Path | Description |
|---|---|
| `src/growthcleanpy/` | Package source code |
| `src/growthcleanpy/reference/` | Bundled growth reference data (WHO/CDC/NHANES/Tanner) |
| `tests/` | Automated regression tests |
| `tests/data/` | Sample input and baseline output for testing |
| `pyproject.toml` | Package configuration and dependencies |
| `run_tests.sh` | Build-and-test automation script |

---

## Running the tests

The automated regression suite verifies that the packaged library reproduces the validated baseline output exactly. Run against a source checkout:

```bash
pip install -e .[dev]
python -m pytest tests/
```

Or run the full build-and-test cycle against a freshly built wheel:

```bash
bash run_tests.sh
```

---

## Releases

Built wheel packages are attached to tagged [Releases](../../releases). Download the `.whl` from the desired release and install as shown above.

---

## Public Domain Standard Notice
This repository constitutes a work of the United States Government and is not
subject to domestic copyright protection under 17 USC § 105. This repository is in
the public domain within the United States, and copyright and related rights in
the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
All contributions to this repository will be released under the CC0 dedication. By
submitting a pull request you are agreeing to comply with this waiver of
copyright interest.

## License Standard Notice
The repository utilizes code licensed under the terms of the Apache Software
License and therefore is licensed under ASL v2 or later.

This source code in this repository is free: you can redistribute it and/or modify it under
the terms of the Apache Software License version 2, or (at your option) any
later version.

This source code in this repository is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the Apache Software License for more details.

You should have received a copy of the Apache Software License along with this
program. If not, see http://www.apache.org/licenses/LICENSE-2.0.html

The source code forked from other open source projects will inherit its license.

## Privacy Standard Notice
This repository contains only non-sensitive, publicly available data and
information. All material and community participation is covered by the
[Disclaimer](DISCLAIMER.md)
and [Code of Conduct](code-of-conduct.md).
For more information about CDC's privacy policy, please visit [http://www.cdc.gov/other/privacy.html](https://www.cdc.gov/other/privacy.html).

## Contributing Standard Notice
Anyone is encouraged to contribute to the repository by [forking](https://help.github.com/articles/fork-a-repo)
and submitting a pull request. (If you are new to GitHub, you might start with a
[basic tutorial](https://help.github.com/articles/set-up-git).) By contributing
to this project, you grant a world-wide, royalty-free, perpetual, irrevocable,
non-exclusive, transferable license to all users under the terms of the
[Apache Software License v2](http://www.apache.org/licenses/LICENSE-2.0.html) or
later.

All comments, messages, pull requests, and other submissions received through
CDC including this GitHub page may be subject to applicable federal law, including but not limited to the Federal Records Act, and may be archived. Learn more at [http://www.cdc.gov/other/privacy.html](http://www.cdc.gov/other/privacy.html).

## Records Management Standard Notice
This repository is not a source of government records, but is a copy to increase
collaboration and collaborative potential. All government records will be
published through the [CDC web site](http://www.cdc.gov).

## Additional Standard Notices
Please refer to [CDC's Template Repository](https://github.com/CDCgov/template) for more information about [contributing to this repository](https://github.com/CDCgov/template/blob/main/CONTRIBUTING.md), [public domain notices and disclaimers](https://github.com/CDCgov/template/blob/main/DISCLAIMER.md), and [code of conduct](https://github.com/CDCgov/template/blob/main/code-of-conduct.md).
