Skip to content

Custom Teva

OMOP-Teva module can also be applied to any dataframe. User must use reduce_table and visualize_table from eds_scikit.plot.table_viz.

Image title

Make sure to specify categorical columns with less then 50 values.

Use the function eds_scikit.plot.table_viz.map_column to reduce columns volumetry.

Creating synthetic dataset
import numpy as np
import pandas as pd

data = pd.DataFrame(
    {
        "id": str(np.arange(1, 1001)),
        "category_1": np.random.choice(["A", "B", "C"], size=1000, p=[0.4, 0.3, 0.3]),
        "category_2": np.array([str(i) for i in range(500)] * 2),
        "location": np.random.choice(
            ["location 1", "location 2"], size=1000, p=[0.6, 0.4]
        ),
        "date": pd.to_datetime(
            np.random.choice(
                pd.date_range(start="2021-01-01", end="2022-01-01"), size=1000
            )
        ),
    }
)
from eds_scikit.plot import reduce_table, visualize_table

data_reduced = reduce_table(
    data,
    category_columns=["location", "category_1", "category_2"],
    date_column="date",
    start_date="2021-01-01",
    end_date="2021-12-01",
    mapper={"category_2": {"even": r"[02468]$", "odd": r"[13579]$"}},
)

chart = visualize_table(
    data_reduced, title="synthetic dataframe table", description=True
)

01002003004005006007008009001,000Sum of countJan 2021Feb 2021Mar 2021Apr 2021May 2021Jun 2021Jul 2021Aug 2021Sep 2021Oct 2021Nov 2021Dec 2021datetime (year-month)050Sum of countlocation 1location 2locationlocation01002003004005006007008009001,000Sum of countJan 2021Feb 2021Mar 2021Apr 2021May 2021Jun 2021Jul 2021Aug 2021Sep 2021Oct 2021Nov 2021Dec 2021datetime (year-month)02040Sum of countABCcategory_1category_101002003004005006007008009001,000Sum of countJan 2021Feb 2021Mar 2021Apr 2021May 2021Jun 2021Jul 2021Aug 2021Sep 2021Oct 2021Nov 2021Dec 2021datetime (year-month)0204060Sum of countevenoddcategory_2category_2synthetic dataframe tableALT + SHIFT to select multiple categoriesDouble-click on legend to unselectReduce table column and values size for better interactivity

Back to top