# pandas 3.1.0 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input

    Create a Table schema from ``data``.

    This method is a utility to generate a JSON-serializable schema
    representation of a pandas Series or DataFrame, compatible with the
    Table Schema specification. It enables structured data to be shared
    and validated in various applications, ensuring consistency and
    interoperability.

    Parameters
    ----------
    data : Series or DataFrame
        The input data for which the table schema is to be created.
    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` will set `'primaryKey'` to the index
        level or levels if the index is unique.
    version : bool, default True
        Whether to include a field `pandas_version` with the version
        of pandas that last revised the table schema. This version
        can be different from the installed pandas version.

    Returns
    -------
    dict
        A dictionary representing the Table schema.

    See Also
    --------
    DataFrame.to_json : Convert the object to a JSON string.
    read_json : Convert a JSON string to pandas object.

    Notes
    -----
    See `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 `any` dtype, and use the `enum` field
    constraint to list the allowed values. The `ordered` attribute is included
    in an `ordered` field.

    Examples
    --------
    >>> from pandas.io.json._table_schema import build_table_schema
    >>> 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', 'extDtype': 'str'}, {'name': 'C', 'type': 'datetime'}], 'primaryKey': ['idx'], 'pandas_version': '1.4.0'}
    
=== parse numpydoc
short_description: 'Create a Table schema from ``data``.'
long_description: |
  This method is a utility to generate a JSON-serializable schema
  representation of a pandas Series or DataFrame, compatible with the
  Table Schema specification. It enables structured data to be shared
  and validated in various applications, ensuring consistency and
  interoperability.
blank_after_short_description: True
blank_after_long_description: True
style: numpydoc
- DocstringParam
  description: 'The input data for which the table schema is to be created.'
  kind: param
  key: 'param'
  arg_name: 'data'
  type_name: 'Series or DataFrame'
  is_optional: False
- DocstringParam
  description: 'Whether to include ``data.index`` in the schema.'
  kind: param
  key: 'param'
  arg_name: 'index'
  type_name: 'bool'
  is_optional: True
  default: 'True'
  raw_type_name: 'bool, default True'
- DocstringParam
  description: |
    Column names to designate as the primary key.
    The default `None` will set `'primaryKey'` to the index
    level or levels if the index is unique.
  kind: param
  key: 'param'
  arg_name: 'primary_key'
  type_name: 'bool or None'
  is_optional: True
  default: 'True'
  raw_type_name: 'bool or None, default True'
- DocstringParam
  description: |
    Whether to include a field `pandas_version` with the version
    of pandas that last revised the table schema. This version
    can be different from the installed pandas version.
  kind: param
  key: 'param'
  arg_name: 'version'
  type_name: 'bool'
  is_optional: True
  default: 'True'
  raw_type_name: 'bool, default True'
- DocstringReturns
  description: 'A dictionary representing the Table schema.'
  kind: returns
  key: 'returns'
  type_name: 'dict'
  is_generator: False
- DocstringMeta
  description: |
    DataFrame.to_json : Convert the object to a JSON string.
    read_json : Convert a JSON string to pandas object.
  kind: text
  key: 'see_also'
  title: 'See Also'
- DocstringMeta
  description: |
    See `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 `any` dtype, and use the `enum` field
    constraint to list the allowed values. The `ordered` attribute is included
    in an `ordered` field.
  kind: text
  key: 'notes'
  title: 'Notes'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> from pandas.io.json._table_schema import build_table_schema'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> 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'))
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> build_table_schema(df)
    {'fields': [{'name': 'idx', 'type': 'integer'}, {'name': 'A', 'type': 'integer'}, {'name': 'B', 'type': 'string', 'extDtype': 'str'}, {'name': 'C', 'type': 'datetime'}], 'primaryKey': ['idx'], 'pandas_version': '1.4.0'}
=== detect
numpydoc
=== compose numpydoc
Create a Table schema from ``data``.

This method is a utility to generate a JSON-serializable schema
representation of a pandas Series or DataFrame, compatible with the
Table Schema specification. It enables structured data to be shared
and validated in various applications, ensuring consistency and
interoperability.

Parameters
----------
data : Series or DataFrame
    The input data for which the table schema is to be created.
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` will set `'primaryKey'` to the index
    level or levels if the index is unique.
version : bool, default True
    Whether to include a field `pandas_version` with the version
    of pandas that last revised the table schema. This version
    can be different from the installed pandas version.

Returns
-------
dict
    A dictionary representing the Table schema.

See Also
--------
DataFrame.to_json : Convert the object to a JSON string.
read_json : Convert a JSON string to pandas object.

Notes
-----
See `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 `any` dtype, and use the `enum` field
constraint to list the allowed values. The `ordered` attribute is included
in an `ordered` field.

Examples
--------
>>> from pandas.io.json._table_schema import build_table_schema
>>> 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', 'extDtype': 'str'}, {'name': 'C', 'type': 'datetime'}], 'primaryKey': ['idx'], 'pandas_version': '1.4.0'}
