pandas 1.4.2

NotesParametersReturnsBackRef
build_table_schema(data: 'DataFrame | Series', index: 'bool' = True, primary_key: 'bool | None' = None, version: 'bool' = True) -> 'dict[str, JSONSerializable]'

Notes

See :None:None:`Table Schema <https://pandas.pydata.org/docs/user_guide/io.html#table-schema>` for conversion types. Timedeltas as converted to ISO8601 duration format with 9 decimal places after the seconds field for nanosecond precision.

Categoricals are converted to the :None:None:`any` dtype, and use the enum field constraint to list the allowed values. The :None:None:`ordered` attribute is included in an :None:None:`ordered` field.

Parameters

data : Series, DataFrame
index : bool, default True

Whether to include data.index in the schema.

primary_key : bool or None, default True

Column names to designate as the primary key. The default :None:None:`None` will set :None:None:`'primaryKey'` to the index level or levels if the index is unique.

version : bool, default True

Whether to include a field :None:None:`pandas_version` with the version of pandas that last revised the table schema. This version can be different from the installed pandas version.

Returns

schema : dict

Create a Table schema from data .

Examples

This example is valid syntax, but we were not able to check execution
>>> df = pd.DataFrame(
...  {'A': [1, 2, 3],
...  'B': ['a', 'b', 'c'],
...  'C': pd.date_range('2016-01-01', freq='d', periods=3),
...  }, index=pd.Index(range(3), name='idx'))
... build_table_schema(df) {'fields': [{'name': 'idx', 'type': 'integer'}, {'name': 'A', 'type': 'integer'}, {'name': 'B', 'type': 'string'}, {'name': 'C', 'type': 'datetime'}], 'primaryKey': ['idx'], 'pandas_version': '1.4.0'}
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.io.json._table_schema.parse_table_schema pandas.io.json._table_schema.build_table_schema

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/io/json/_table_schema.py#214
type: <class 'function'>
Commit: