pandas.io.json.build_table_schema
-
pandas.io.json.build_table_schema(data, index=True, primary_key=None, version=True)[source] -
Create a Table schema from
data.Parameters: -
data : Series, DataFrame
index : bool, default True
Whether to include
data.indexin the schema.primary_key : bool or None, default True
column names to designate as the primary key. The default
Nonewill set‘primaryKey’to the index level or levels if the index is unique.version : bool, default True
Whether to include a field
pandas_versionwith the version of pandas that generated the schema.Returns: -
schema : dict
Notes
See
_as_json_table_typefor conversion types. Timedeltas as converted to ISO8601 duration format with 9 decimal places after the secnods field for nanosecond precision.Categoricals are converted to the
anydtype, and use theenumfield constraint to list the allowed values. Theorderedattribute is included in anorderedfield.Examples
>>> 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'}], 'pandas_version': '0.20.0', 'primaryKey': ['idx']} -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.io.json.build_table_schema.html