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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fdth-1.0.1.tar.gz.
File metadata
- Download URL: fdth-1.0.1.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f39315623b6c1117e0fbc594ef1fb7f9af48ef986d991f8cf1ba97180f5284ab
|
|
| MD5 |
28b9235bd1344215543ee0b33845ed82
|
|
| BLAKE2b-256 |
ae496033029cdbda04fe7ad04a75e96d6bb913c4f7cebc3cc78d3cc1dc30e2b2
|
File details
Details for the file fdth-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fdth-1.0.1-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
767ccb1d302facfb6df5f125fee46e2d206d6c09478796c206d83fb72a261093
|
|
| MD5 |
1931878e7957cefb8c3f016d4f58970d
|
|
| BLAKE2b-256 |
2b7304dbf6554285dca82d2aa4ecaed85b8245b28e53d7afeb98b36b9c9d8e9c
|