opensafely-actions / safetab

Safetab outputs two-way tables of descriptive statistics
Other
0 stars 0 forks source link

Set up #1

Closed CarolineMorton closed 3 years ago

CarolineMorton commented 3 years ago

Basic structure set up with unit tests.

This takes in a python dict such as:

{
  "simple_2_way_tabs":
    {"tab_type": "2-way", 
    "variables": ["sex", "ageband", "copd", "death"] },
  "death_2_way_tabs":
    {"tab_type": "target-2-way",
     "variables": ["sex", "ageband", "copd"],
     "target": "death"},
  "grouped_by_sex":
    {
      "tab_type": "group_by_2-way",
      "variables": ["copd", "death"],
      "group_by": "sex",
    },
}

NOTE: This will have to be loaded in from yaml/json

It then creates all the tables, and redacts low numbers. A log of tables is created in a file called table_log.txt. The tables themselves are saved in a folder of specified in the yaml, for example, with the above input, you would end up with a folder called simple_2_way_tabs/ and another called grouped_by_sex/.

Tables are outputted in formatted Markdown as this can be viewed on Github or with IDE on server such as VS.

All tables have 3 outputs:

  1. Raw numbers with totals
  2. Raw numbers with extra columns for column percentages, rounded to nearest 1
  3. Raw numbers with extra column for row percentages, rounded to the nearest 1
CarolineMorton commented 3 years ago

This is very much a work in progress @sebbacon, not a finished product.