pdstools.explanations.ExplanationsUtils

Attributes

Classes

ContextInfo

dict() -> new empty dictionary

ContextOperations

Context related operations such as to filter unique contexts.

Module Contents

SortBy
DisplayBy
ContributionType
class ContextInfo

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

context_key: str
context_value: str
class ContextOperations(aggregate: pdstools.explanations.Aggregate.Aggregate)

Bases: pdstools.utils.namespaces.LazyNamespace

Context related operations such as to filter unique contexts.

Parameters:
aggregate(Aggregate)
Type:

The aggregate object.

_df(pl.DataFrame | None)
Type:

DataFrame containing context information.

_context_keys(list[str] | None)
Type:

list of context keys.

initialized(bool)
Type:

Flag indicating if the context operations have been initialized.

get_context_keys():

Returns the list of context keys from loaded data. Eg. [‘pyChannel’, ‘pyDirection’, …]

get_df(context_infos=None, with_partition_col=False):

Returns a DataFrame containing unique contexts If with_partition_col is True, includes the partition column. If context_infos is None, returns the full unique contexts, else filtered by the context Eg. with partition column: | pyChannel | pyDirection | … | partition | |-----------|————-|-----|———–| | channel1 | direction1 | … | {“partition”: {“pyChannel”: “channel1”, “pyDirection”: “direction1”}} | | channel1 | direction2 | … | {“partition”: {“pyChannel”: “channel1”, “pyDirection”: “direction2”}} |

get_list(context_infos=None, with_partition_col=False):

Returns a list[ContextInfo] containing unique contexts If with_partition_col is True, includes the partition column. If context_infos is None, returns the full unique contexts, else filtered by the context Eg. without partition column: [

{“pyChannel”: “channel1”, “pyDirection”: “direction1”, …}, {“pyChannel”: “channel1”, “pyDirection”: “direction2”, …},

]

get_context_info_str(context_info, sep="-"):

Returns a string representation of a single context information. Eg. channel1-direction1-…

dependencies = ['polars']
dependency_group = 'explanations'
aggregate
initialized = False
get_context_keys() list[str]
Return type:

list[str]

get_df(context_infos: list[ContextInfo] | None = None, with_partition_col: bool = False) polars.DataFrame

Get the DataFrame filtered by the provided context information.

Parameters:
Return type:

polars.DataFrame

get_list(context_infos: list[ContextInfo] | None = None, with_partition_col: bool = False) list[ContextInfo]

Get the list of context information filtered by the provided context information.

Parameters:
Return type:

list[ContextInfo]

static get_context_info_str(context_info: ContextInfo, sep: str = '-') str
Parameters:
Return type:

str