fdth
Frequency distribution tables, histograms, and polygons for numerical and categorical data in Python.
A feature-complete port of the fdth R package (CRAN).
pip install fdth
Package page: pypi.org/project/fdth · Release notes: NEWS.md
Alternative installs (source / repo wheel):
pip install git+https://github.com/jcfaria/fdth-python.git
pip install https://github.com/jcfaria/fdth-python/raw/main/dist/fdth-1.0.1-py3-none-any.whl
Canonical repository: github.com/jcfaria/fdth-python
Features
- Frequency distribution tables (FDT) from lists, NumPy arrays, and pandas objects
- Numerical and categorical variables, plus multi-column / grouped tables
- Histograms and frequency polygons (absolute, relative, cumulative)
- Summary measures from grouped data (mean, median, mode, quantiles, variance, …)
- Grouping with multiple keys via
by=(beyond the original R single-key limit)
Requires Python 3.10+. Depends on pandas, numpy, and matplotlib.
Quick start
from fdth import fdt
data = [1, 5, 8, 3, 12, 7, 4, 9]
table = fdt(data)
print(table)
table.plot()
fdt() detects the data type and returns NumericalFDT, CategoricalFDT, or
MultipleFDT as appropriate.
Grouped example
Build FDTs for every column, split by several grouping variables, and plot:
import pandas as pd
from fdth import fdt
df = pd.DataFrame({
"Height": [170, 175, 180, 165, 172, 168, 175, 170, 160, 155],
"Weight": [70, 75, 80, 65, 72, 68, 75, 70, 60, 55],
"Age": [30, 20, 30, 18, 30, 27, 24, 50, 60, 9],
"Sex": ["M", "I", "M", "I", "M", "F", "I", "F", "F", "F"],
"Region": [
"Northeast", "Southeast", "Northeast", "Southeast", "North",
"North", "Southeast", "Northeast", "North", "Southeast",
],
"MaritalStatus": [
"Married", "Single", "Single", "Married", "Single",
"Single", "Married", "Married", "Single", "Married",
],
})
mfdt = fdt(df, by=["Sex", "MaritalStatus", "Region"])
mfdt.plot(numeric_type="fh", categorical_type="fb")
Page 1
Page 2
More notebooks and mirrored .py scripts live under examples/Python.
Comparable R examples are under examples/R.
Development
git clone https://github.com/jcfaria/fdth-python.git
cd fdth-python
python -m venv venv
# Linux / macOS: source venv/bin/activate
# Windows CMD: venv\Scripts\activate.bat
# Windows PS: venv\Scripts\Activate.ps1
pip install -e ".[dev]"
| Task | Command |
|---|---|
| Tests | python -m unittest discover -s tests |
| Format | black . |
| Type check | mypy --strict --cache-fine-grained . |
| API docs | pdoc -o doc fdth |
| Build | python -m build |
A short Git tutorial in Portuguese is available in HelpGit.md.
Background
This package is a collective Python port of the R fdth library, developed at UESC (Computer Science — Probability and Statistics) with successive student cohorts and earlier community ports. The object-oriented design solidified over that collaborative work. The public reference repository is jcfaria/fdth-python; version 1.0.1 is on PyPI.
Credits
Original R package — jcfaria/fdth
Initial Python port — yuriccosta/fdth-python
UESC collaborators — first course cohort — Gabriel Galdino, Luciene Mª Torquato C. Batista, Stella Ribas, Thainá Guimarães, Yohanan Santana
UESC collaborators — second course cohort — Alex Amaral dos Santos, Isaque Silva Passos Ribeiro, Kaiala de Jesus Santos, Olinoedson Silva Sena
UESC collaborators — PyPI 1.0.0 release — Ariel Mariano Vieira, Eduardo Ferreira Diniz da Silva, Pedro Lucas do Nascimento de Oliveira
Author / Maintainer
Faria, J. C.
Universidade Estadual de Santa Cruz — UESC
Departamento de Ciências Exatas — DCEX
Ilhéus — Bahia — Brazil
- Email: joseclaudio.faria@gmail.com
- GitHub: jcfaria
- R package: GitHub · CRAN
License
This package is free software under the GNU General Public License, version 2 (GPL-2.0).
See LICENSE for the full text.
Release files for fdth 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fdth-1.0.1.tar.gz | 31.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fdth-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.3 kB
Release files / fdth-1.0.1.tar.gz
| Download URL | fdth-1.0.1.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f39315623b6c1117e0fbc594ef1fb7f9af48ef986d991f8cf1ba97180f5284ab
|
|
BLAKE2b-256 checksum How to use checksums |
ae496033029cdbda04fe7ad04a75e96d6bb913c4f7cebc3cc78d3cc1dc30e2b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.10
|
Release files / fdth-1.0.1-py3-none-any.whl
| Download URL | fdth-1.0.1-py3-none-any.whl |
|---|---|
| Size | 28.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
767ccb1d302facfb6df5f125fee46e2d206d6c09478796c206d83fb72a261093
|
|
BLAKE2b-256 checksum How to use checksums |
2b7304dbf6554285dca82d2aa4ecaed85b8245b28e53d7afeb98b36b9c9d8e9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.10
|