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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tlfs-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ed238cd30b72d3db42c56485ffe5608af768872ba6133445765918216f69c8e5
MD5 8f58a7118dc145bb5e4c3d385c2397db
BLAKE2b-256 e30f5aa60ac3b3462e8694d52c60d7b6bdb71933d42b81f668e1b69ec720bd0e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tlfs-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8d5ec47e8e29a7bdb99dd1b047de39e5d744a6d4a27c159f32443892d5bf3877
MD5 b30ab8c1d9fc702ea56c6b8856325142
BLAKE2b-256 80ec0f091485da12f73996a5f3cf82c5943583e6289e42d0b54c4d4708436000

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