pdstools.utils.streamlit_utils

Module Contents

Functions

cachedSample()

cachedDatamart(*args, **kwargs)

import_datamart(**opts)

fromUploadedFile(**opts)

fromFilePath(**opts)

model_selection_df(df, context_keys)

filter_dataframe(→ polars.LazyFrame)

Adds a UI on top of a dataframe to let viewers filter columns

model_and_row_counts(df)

Returns unique model id count and row count from a dataframe

configure_predictor_categorization()

convert_df(df)

process_files(→ Tuple[bytes, str])

Processes a list of file paths. If there's only one file, returns the file's content as bytes

cachedSample()
cachedDatamart(*args, **kwargs)
import_datamart(**opts)
fromUploadedFile(**opts)
fromFilePath(**opts)
model_selection_df(df: polars.LazyFrame, context_keys: list)
Parameters:
  • df (polars.LazyFrame)

  • context_keys (list)

filter_dataframe(df: polars.LazyFrame, schema: dict | None = None, queries=[]) polars.LazyFrame

Adds a UI on top of a dataframe to let viewers filter columns

Parameters:
  • df (pl.DataFrame) – Original dataframe

  • schema (Optional[dict])

Returns:

The filtered LazyFrame

Return type:

pl.LazyFrame

model_and_row_counts(df: pdstools.utils.types.any_frame)

Returns unique model id count and row count from a dataframe

Parameters:

df (Union[pl.DataFrame, pl.LazyFrame]) – The input dataframe

Returns:

unique model count row count

Return type:

Tuple[int, int]

configure_predictor_categorization()
convert_df(df)
process_files(file_paths: List[str], file_name: str) Tuple[bytes, str]

Processes a list of file paths. If there’s only one file, returns the file’s content as bytes and the provided file name. If there are multiple files, creates a zip file containing all the files and returns the zip file’s data as bytes and the generated zip file name.

Parameters:
  • file_paths (List[str]) – A list of file paths to process.

  • file_name (str) – The file name to use when returning the file or zip file’s name.

Returns:

The content of the single file as bytes and the file name if there’s only one file, or the zip file’s data as bytes and the zip file’s name if there are multiple files.

Return type:

(bytes, str)