Data#

DataAdapter#

class gufo.data.adapter.DataAdapter(data)[source]#

Bases: object

Wraps any supported input data into a common interface.

Marks never receive raw DataFrames or dicts. They call DataAdapter.resolve(key) and get back a numpy array.

Supported input types:

pandas.DataFrame — column access by string key polars.DataFrame — column access by string key (optional dependency) dict — key access None — no bound data; x/y must be arrays/lists directly

__init__(data)[source]#
property raw_data#

The original data object passed to the adapter.

property data_type#

String identifying the data backend: ‘dataframe’, ‘polars’, ‘dict’, or ‘none’.

classmethod from_any(data)[source]#
column_names()[source]#

Return list of column names from bound data.

resolve(key)[source]#

Return key as a numpy array.

key may be:

str — column name looked up in bound data list of str — multiple columns (wide-form); returns list of arrays array-like — returned as numpy array directly

subset(mask)[source]#

Return a new DataAdapter containing only rows where mask is True.

Type inference#

gufo.data.inference.is_categorical(arr)[source]#

Return True if arr should be treated as a categorical variable.