Classes and scripts to create TLFs (Table, Listing, Figures shells) quickly and in an opinionated way.
Project description
tlfs
Table of Contents
Installation
pip install tlfs
License
tlfs
is distributed under the terms of the
MIT license.
Example usage
For some "standard" (opinionated) stuff you could do the following (which is what is done in the web version on streamlit):
tlf = TLF("Test")
tlf.from_xlsx("path-to-your.xlsx")
tlf
tlf.to_docx("path-to-your.docx")
For custom stuff one has to program by hand:
# overloading * Quant/Quali/Itemset to create Tables quickly
age = Quant("Age")
sex = Quali("Sex", groups = ["M", "F"])
trt = Quali("Treatment", groups = ["EXP", "CTRL"])
prices = Itemset("Unit costs",
items = ["Dentist", "Hospice", "Blood test"],
contents = ["unit cost", "per", "source"])
nation = Quali("Nation", groups = ["UK", "ITA"])
age * trt
[var * trt for var in [age, sex]] + [prices * nation]
# Changing display default in a table
age2 = Quant("Age", display = ["median", "25pct", "75pct"], unit = 'years')
age3 = Quant("Age", display = "median (iqr)", cell_content = "xx (xx - xx)")
sex2 = Quali("Sex", groups = ["M", "F"], display = "n", cell_content = "x")
univ = Section("Univariate tables", [Table(age), Table(sex)])
changed_def = Section("Some changed defaults", [Table(age2), age2 * trt, age3 * trt, Table(sex2)])
listings = Section("Listings", [Table(prices), prices * nation])
tlf2 = TLF("Table, Listings, Figure examples", [univ, biv, changed_def, listings])
tlf.to_doc("whatever.docx")
TODO
- add random figures/graphs
- table/figure numbering?
- overload + in
Table
to stack them - overload + in
Sections
to concatenate them - just do
Section("Univariate tables", [age, sex])
instead ofSection("Univariate tables", [Table(age), Table(sex)])
- "UK|Control", "UK|Intervention", "Tot|Control", "Tot|Intervention", by three way tables
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tlfs-0.0.5.tar.gz
(34.6 kB
view details)
Built Distribution
tlfs-0.0.5-py3-none-any.whl
(7.9 kB
view details)
File details
Details for the file tlfs-0.0.5.tar.gz
.
File metadata
- Download URL: tlfs-0.0.5.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eae88f34e5493128061e4d181b7c284a18c2382941e47e8d3567c304d9076566 |
|
MD5 | e109191ca20ed3d391e0d81e42a849ce |
|
BLAKE2b-256 | 257edbf68f7589d5c7f54725378894a2e35fb958f949a10d89966975da9bf5fc |
File details
Details for the file tlfs-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: tlfs-0.0.5-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa73456e416634872a2424db49872379890ea56b489fee943f88c17ca45b97b4 |
|
MD5 | e36cc961e4cafb6467c7a2abe980ea71 |
|
BLAKE2b-256 | a5cece5245018e9d583aedbc46a17410eaa6774e1dff865e4b18768f15725fa9 |