pasteur.attribute.Grouping#

class pasteur.attribute.Grouping(type, arr, title=None)[source]#

An enchanced form of list that holds the type of grouping (categorical, ordinal), and implements helper functions and an enchanced string representation.

Attributes

height

size

Methods

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

from_str(a[, nullable, ukn_val])

rtype:

Grouping

get_dict_mapping(height)

rtype:

dict[int, int]

get_domain(height)

get_groups(height)

rtype:

list[list | int]

get_human_values()

rtype:

list[str]

get_mapping(height)

rtype:

ndarray

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

append(object, /)#

Append object to the end of the list.

clear()#

Remove all items from list.

copy()#

Return a shallow copy of the list.

count(value, /)#

Return number of occurrences of value.

extend(iterable, /)#

Extend list by appending elements from the iterable.

static from_str(a, nullable=False, ukn_val=None)[source]#
Return type:

Grouping

get_dict_mapping(height)[source]#
Return type:

dict[int, int]

get_domain(height)[source]#
get_groups(height)[source]#
Return type:

list[list | int]

get_human_values()[source]#
Return type:

list[str]

get_mapping(height)[source]#
Return type:

ndarray

property height: int#
index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)#

Insert object before index.

pop(index=-1, /)#

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)#

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()#

Reverse IN PLACE.

property size: int#
sort(*, key=None, reverse=False)#

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.