sampotools.api.gen_asd_from_pandas_df

sampotools.api.gen_asd_from_pandas_df(df)

Generates an ASD object from input DataFrame. Since the DataFrame column name is used in attribute name, the DataFrame must be specified column name. If the column name is None or dtype is not supported, the column is skipped.

Supported schema types are as follows:

Data type

SAMPO

numpy.float64

REAL

numpy.uint64

INTEGER

numpy.int64

INTEGER

numpy.bool

NOMINAL

numpy.datetime64

DATE

numpy.timedelta64

DATE

numpy.str

NOMINAL

numpy.object

NOMINAL

The type can convert to numpy.str

NOMINAL

Parameters
dfpandas.DataFrame

Input DataFrame.

Returns
asd_objectOrderedDict

Attribute schema. See ASD object.

Note

Checking whether the attribute scales and domains are properly generated is strongly recommended.

Raises
ValueError
  • If input DataFrame has not string column name.

  • If input DataFrame has same column name.

Examples

>>> import pandas as pd
>>> from sampotools.api import gen_asd_from_pandas_df
>>> learn_df = pd.read_csv('data/fabhmerg_learn.csv')
>>> asd = gen_asd_from_pandas_df(learn_df)