modlee.dataframes module

class modlee.dataframes.DataFrameTransforms[source]

Bases: object

Transforms for a dataframe. Inspired by torchvision’s transforms.

static compose(transforms)[source]
static drop_nonnum(df)[source]
static dropna(df)[source]
static fillna(df, val=0)[source]
static list_cols2item(df)[source]
static normalize(df)[source]
static obj2num(df)[source]
static scale(df, scaler=None)[source]

Cannot use this in compose because it also returns the scaler

class modlee.dataframes.ModleeDataFrame(data=None, index: Collection[Any] | None = None, columns: Collection[Any] | None = None, dtype: ExtensionDtype | str | dtype | Type[str | float | int | complex | bool | object] | None = None, copy: bool | None = None)[source]

Bases: DataFrame

A wrapper class over a pandas DataFrame with convenience functions for metafeatures.

to_tsv(*args, **kwargs)[source]

Save a dataframe to a tab-separated value file. Wraps around and passes arguments to pd.DataFrame.to_csv().

to_txt(path, columns=None, apply_fn=None, *args, **kwargs)[source]

Save a column of a dataframe

Parameters:
  • path – The path to save the txt to.

  • columns – The columns of the dataframe to save, defaults to None

  • apply_fn – An optional function to apply to the dataframe (i.e. pd.DataFrame.apply(apply_fn)), defaults to None

modlee.dataframes.default_transforms(df)