typespecs.api module#

typespecs.api.from_annotated(obj: ~typing.Any, /, data: str | None = 'data', default: dict[str, ~typing.Any] | ~typing.Any = <NA>, merge: bool = True, separator: str = '/', type: str | None = 'type') DataFrame[source]#

Create a specification DataFrame from given object with annotations.

Parameters:
  • obj – The object to convert.

  • data – Name of the column for the actual data of the annotations. If it is None, the data column will not be created.

  • default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.

  • merge – Whether to merge all sub-annotations into a single row. If it is False, each sub-annotation will have its own row.

  • separator – Separator for concatenating root and sub-indices.

  • type – Name of the column for the metadata-stripped annotations. If it is None, the type column will not be created.

Returns:

Created specification DataFrame.

typespecs.api.from_annotation(obj: ~typing.Any, /, *, default: dict[str, ~typing.Any] | ~typing.Any = <NA>, index: str = 'root', merge: bool = True, separator: str = '/', type: str | None = 'type') DataFrame[source]#

Create a specification DataFrame from given annotation.

Parameters:
  • obj – The annotation to convert.

  • default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.

  • index – Root index of the created specification DataFrame.

  • merge – Whether to merge all sub-annotations into a single row. If it is False, each sub-annotation will have its own row.

  • separator – Separator for concatenating root and sub-indices.

  • type – Name of the column for the metadata-stripped annotations. If it is None, the type column will not be created.

Returns:

Created specification DataFrame.

typespecs.api.from_annotations(obj: dict[str, ~typing.Any], /, *, default: dict[str, ~typing.Any] | ~typing.Any = <NA>, merge: bool = True, separator: str = '/', type: str | None = 'type') DataFrame[source]#

Create a specification DataFrame from given annotations.

Parameters:
  • obj – The annotations to convert.

  • default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.

  • merge – Whether to merge all sub-annotations into a single row. If it is False, each sub-annotation will have its own row.

  • separator – Separator for concatenating root and sub-indices.

  • type – Name of the column for the metadata-stripped annotations. If it is None, the type column will not be created.

Returns:

Created specification DataFrame.