Skip to main content

Classes and scripts to create TLFs (Table, Listing, Figures shells) quickly and in an opinionated way.

Project description

tlfs

PyPI - Version PyPI - Python Version


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

  • overload + in Table to stack them
  • overload + in Sections to concatenate them
  • just do Section("Univariate tables", [age, sex]) instead of Section("Univariate tables", [Table(age), Table(sex)])

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.4.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

tlfs-0.0.4-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file tlfs-0.0.4.tar.gz.

File metadata

  • Download URL: tlfs-0.0.4.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for tlfs-0.0.4.tar.gz
Algorithm Hash digest
SHA256 af221be3711677bf14db86741ace65e77074a42b30707c33d64b93321daed034
MD5 312f88a9590898b30f2a3153e526a4b7
BLAKE2b-256 3cff8f8d590f7b24e79e830ed4f532e1f659948969e52c7b299ad63f1321a573

See more details on using hashes here.

File details

Details for the file tlfs-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: tlfs-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for tlfs-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 193d713e160c3f58630ae5681606e319226388561c69e436edc35017a55d232c
MD5 5ac19d73c0a6ef6ee8ebec3355b53b17
BLAKE2b-256 3d97dd0c642425511b3a96923723b29d6262cadd3342cb25010a7f0245438076

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page