Unique

class grizli.utils.Unique(array, verbose=True)[source]

Bases: object

Helper for unique items in an array

Parameters
arrayarray-like

Data to parse, generally strings but can be anything that can be parsed by numpy.unique

verbosebool, optional

If True, print a summary of the unique values and their counts. Default is False.

Attributes
dimint

size of input array

valueslist

Unique elements of array

indiceslist

Integer list length of array with the indices of values for each element

countslist

Counts of each element of values

Methods

__iter__()

Iterable over values attribute

__get__(key)

Return a bool array where entries of array match the specified key

Attributes Summary

N

Number of unique values

list_indices

Build list of lists of indices that each unique value

Methods Summary

count(key)

Get occurrences count of a particular value.

info([sort_counts])

Print a summary

unique_index([index])

Return array of indices of the parent array that makes a unique output array

Attributes Documentation

N

Number of unique values

list_indices

Build list of lists of indices that each unique value

Methods Documentation

count(key)[source]

Get occurrences count of a particular value.

Parameters
keyobject

The value to count occurrences of.

Returns
countint

The number of occurrences of the specified value.

info(sort_counts=0)[source]

Print a summary

Parameters
sort_countsint, optional

Sort the counts in ascending order if sort_counts is non-zero. Default is 0.

unique_index(index=0)[source]

Return array of indices of the parent array that makes a unique output array

Parameters
indexint, optional

The index of the value to return. Default is 0.

Returns
uixlist

List of unique indices