Utilities#
Utility functions and classes.
- lydata.utils.get_github_auth(token: str | None = None, user: str | None = None, password: str | None = None) Auth | None[source]#
Get the GitHub authentication object from arguments or environment variables.
- lydata.utils.update_and_expand(left: DataFrame, right: DataFrame, **update_kwargs: Any) DataFrame[source]#
Update
leftwith values fromright, also adding columns fromright.The added feature of this function over pandas’
update()is that it also adds columns that are present inrightbut not inleft.Any keyword arguments are also directly passed to the
update().>>> left = pd.DataFrame({"a": [1, 2, None], "b": [3, 4, 5]}) >>> right = pd.DataFrame({"a": [None, 3, 4], "c": [6, 7, 8]}) >>> update_and_expand(left, right) a b c 0 1.0 3 6 1 3.0 4 7 2 4.0 5 8
- lydata.utils.replace(left: DataFrame, right: DataFrame) DataFrame[source]#
Replace all columns in
leftwith those fromright.
- lydata.utils.get_default_column_map_old() _ColumnMap[source]#
Get the old default column map.
This map defines which short column names can be used to access columns in the DataFrames.
>>> from lydata import accessor, loader >>> df = next(loader.load_datasets( ... institution="usz", ... repo_name="lycosystem/lydata.private", ... ref="ab04379a36b6946306041d1d38ad7e97df8ee7ba", ... )) >>> df.ly.surgery 0 False ... 286 False Name: (patient, #, neck_dissection), Length: 287, dtype: bool >>> df.ly.smoke 0 True ... 286 True Name: (patient, #, nicotine_abuse), Length: 287, dtype: bool
- lydata.utils.is_old(dataset: DataFrame) bool[source]#
Check if the dataset uses the old column names.
- lydata.utils.get_default_column_map_new() _ColumnMap[source]#
Get the old default column map.
This map defines which short column names can be used to access columns in the DataFrames.
>>> from lydata import accessor, loader >>> df = next(loader.load_datasets( ... institution="usz", ... repo_name="lycosystem/lydata.private", ... ref="fb55afa26ff78afa78274a86b131fb3014d0ceea", ... )) >>> df.ly.surgery 0 False ... 286 False Name: (patient, core, neck_dissection), Length: 287, dtype: bool >>> df.ly.smoke 0 True ... 286 True Name: (patient, core, nicotine_abuse), Length: 287, dtype: bool
- class lydata.utils.ModalityConfig(*, spec: Annotated[float, Ge(ge=0.5), Le(le=1.0)], sens: Annotated[float, Ge(ge=0.5), Le(le=1.0)], kind: Literal['clinical', 'pathological'] = 'clinical')[source]#
Define a diagnostic or pathological modality.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- lydata.utils.get_default_modalities() dict[str, ModalityConfig][source]#
Get defaults values for sensitivities and specificities of modalities.
Taken from de Bondt et al. (2007) and Kyzas et al. (2008).