https://github.com/data-centt/percentify
https://github.com/data-centt/percentify
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/data-centt/percentify
- Owner: data-centt
- License: apache-2.0
- Created: 2025-09-20T20:36:00.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-03-23T16:15:40.000Z (4 months ago)
- Last Synced: 2026-03-24T13:49:26.710Z (4 months ago)
- Language: Python
- Size: 59.6 KB
- Stars: 78
- Watchers: 0
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-python - percentify - Exploratory stats and data-quality diagnostics/profiler, that supports both pandas and Polars DataFrames inputs. (Projects / Data Analysis)
README
# % Percentify %
[](https://pepy.tech/projects/percentify)
[](https://pypi.org/project/percentify/)
[](https://pypi.org/project/percentify/)
[](LICENSE)
[](https://github.com/data-centt/percentify/actions/workflows/python-app.yml)
**Percentify** is a Python helper that turns *"part of a whole"* into a clean percentage.
Stop typing `(part / whole) * 100` and worrying about division by zero.
---
## β¨ What It Does
Percentify gives you a single function:
- Calculates what percentage one number is of another.
- Handles divide-by-zero safely (returns 0.0 instead of crashing).
- Lets you choose how many decimal places you want to round your answer to.
- Has zero dependencies β just pure Python.
## π¦ Installation
```
pip install percentify
```
### Usage
```
from percentify import percent
# Basic usage
percent(50, 200) # β 25.0
# Handles fractions
percent(1, 3) # β 33.33
# Safe when dividing by zero
percent(5, 0) # β 0.0
# Custom decimals
percent(7, 9, 4) # β 77.7778
```
### π οΈ How It Works
The library is intentionally simple;
```
def percent(part: float, whole: float, decimals: int = 2) -> float:
if whole == 0:
return 0.0
return round((part / whole) * 100, decimals)
```
Thatβs it. Clean, safe, and ready to use anywhere you need percentages in your code.
# π€ Contributing
Contributions are welcome!
- If you have an idea (extra helpers, bug fixes or an idea):
- Fork this repo
- Create a branch
- Commit your changes
- Open a pull request
I try to keep it tiny on purpose, to discuss big new features first.