Skip to main content

Build analytical tables for clinicedc/edc projects

Project description

pypi downloads

edc-analytics

Build analytic tables from EDC data

Read your data into a dataframe, for example an EDC screening table:

qs_screening = SubjectScreening.objects.all()
df = read_frame(qs_screening)

Convert all numerics to pandas numerics:

cols = [
    "age_in_years",
    "dia_blood_pressure_avg",
    "fbg_value",
    "hba1c_value",
    "ogtt_value",
    "sys_blood_pressure_avg",
]
df[cols] = df[cols].apply(pd.to_numeric)

Pass the dataframe to each Table class

gender_tbl = GenderTable(main_df=df)
age_tbl = AgeTable(main_df=df)
bp_table = BpTable(main_df=df)

In the Table instance,

  • data_df is the supporting dataframe

  • table_df is the dataframe to display. The table_df displays formatted data in the first 5 columns (“Characteristic”, “Statistic”, “F”, “M”, “All”). The table_df has additional columns that contain the statistics used for the statistics displayed in columns [“F”, “M”, “All”].

From above, gender_tbl.table_df is just a dataframe and can be combined with other table_df dataframes using pd.concat() to make a single table_df.

table_df = pd.concat(
    [gender_tbl.table_df, age_tbl.table_df, bp_table.table_df]
 )

Show just the first 5 columns:

table_df.iloc[:, :5]

Like any dataframe, you can export to csv:

path = "my/path/to/csv/folder/table_df.csv"
table_df.to_csv(path_or_buf=path, encoding="utf-8", index=0, sep="|")

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

edc_analytics-0.1.4.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

edc_analytics-0.1.4-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file edc_analytics-0.1.4.tar.gz.

File metadata

  • Download URL: edc_analytics-0.1.4.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for edc_analytics-0.1.4.tar.gz
Algorithm Hash digest
SHA256 bc450f42becf58d407b8d47eb3796daaf08b1496ebfca7f0e4c0d72a3e6c1d8a
MD5 f2a23339add10753a633242b6998b23a
BLAKE2b-256 d00e0cbdcad57af395af62110ff2859b5dd64fd4f118a901b8f37885756691f3

See more details on using hashes here.

File details

Details for the file edc_analytics-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for edc_analytics-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ec769c082d2fac7fab159024b174eed56aca4a54d69c3f5d47f2a1906f7e316f
MD5 989c5793941b12c64c215b0bacd35dd1
BLAKE2b-256 1b754d9c749953bb840afe3ff4ae2c2477c7ae64c75c246ad6af53a2607f9c7e

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