aito.schema.AitoTableSchema

class aito.schema.AitoTableSchema(columns: Dict[str, aito.schema.AitoColumnTypeSchema])

Aito Table schema contains the columns and their schema

Can be thought of as a dict-like container for AitoColumnTypeSchema objects

Infer AitoTableSchema from a Pandas DataFrame

>>> df = pd.DataFrame(data={'id': [1, 2], 'name': ['Neil', 'Buzz']})
>>> table_schema = AitoTableSchema.infer_from_pandas_data_frame(df)
>>> table_schema
{
    "columns": {
        "id": {
            "nullable": false,
            "type": "Int"
        },
        "name": {
            "nullable": false,
            "type": "String"
        }
    },
    "type": "table"
}
>>> table_schema['name']
{
    "nullable": false,
    "type": "String"
}
>>> table_schema['name'].nullable = True
>>> table_schema['name']
{
    "nullable": true,
    "type": "String"
}

change the property of a column

Parameters

columns (Dict[str, AitoColumnTypeSchema]) – a dictionary of the table’s columns’ name and scheam

Methods

add_column(column_name, column_schema)

add a column to the table schema

from_deserialized_object(obj)

create an AitoSchema object from a JSON deserialized object

from_json_string(json_string, **kwargs)

create an AitoSchema object from a JSON string

has_column(column_name)

check if the table has the specified column

infer_from_pandas_data_frame(df[, …])

Infer a TableSchema from a Pandas DataFrame

to_json_serializable()

convert the AitoSchema object to a json serializable object (dict, in most case)

to_json_string(**kwargs)

the AitoSchema object as a JSON string

Attributes

columns

return

list of the table’s columns name

columns_schemas

return

the table columns and its schemas

comparison_properties

iterable of the properties that will be used for comparison with another schema object of the same type

links

return

dictionary of the table column and its link

type

the type of the schema component