+
    xȇiD/                    V   R t ^ RIHt ^ RIHtHtHt ^ RIt^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHt ^ RIHtHtHtHt ^ RIH t  ^ RI!H"u H#t$ ^ RI%H&t& ]'       d   ^ RI'H(t(H)t) ^ RIH*t* ^ RI+H,t, Rt-R R lt.R t/R R lt0R R lt1RR R llt2R R lt3R# )zH
Table Schema builders

https://specs.frictionlessdata.io/table-schema/
)annotations)TYPE_CHECKINGAnycastN)option_context)lib)ujson_loads)	timezones)find_stack_level)	_registry)is_bool_dtypeis_integer_dtypeis_numeric_dtypeis_string_dtype)CategoricalDtypeDatetimeTZDtypeExtensionDtypePeriodDtype)	DataFrame)	to_offset)DtypeObjJSONSerializable)Series)
MultiIndexz1.4.0c                    V ^8  d   QhRRRR/# )   xr   returnstr )formats   "l/Users/max/.openclaw/workspace/postharvest/venv/lib/python3.14/site-packages/pandas/io/json/_table_schema.py__annotate__r"   7   s     + +( +s +    c                R   \        V 4      '       d   R# \        V 4      '       d   R# \        V 4      '       d   R# \        P                  ! V R4      '       g   \        V \        \        34      '       d   R# \        P                  ! V R4      '       d   R# \        V 4      '       d   R# R	# )
a<  
Convert a NumPy / pandas type to its corresponding json_table.

Parameters
----------
x : np.dtype or ExtensionDtype

Returns
-------
str
    the Table Schema data types

Notes
-----
This table shows the relationship between NumPy / pandas dtypes,
and Table Schema dtypes.

==============  =================
Pandas type     Table Schema type
==============  =================
int64           integer
float64         number
bool            boolean
datetime64[ns]  datetime
timedelta64[ns] duration
object          str
categorical     any
=============== =================
integerbooleannumberMdatetimemdurationstringany)	r   r   r   r   is_np_dtype
isinstancer   r   r   )r   s   &r!   as_json_table_typer0   7   sx    < 	q			!			C	 	 Jq?K2P$Q$Q	C	 	 			r#   c                .   \         P                  ! V P                  P                  !  '       d   V P                  P                  p\	        V4      ^8X  d>   V P                  P
                  R8X  d#   \        P                  ! R\        4       R7       V # \	        V4      ^8  d[   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d!   \        P                  ! R\        4       R7       V # V P                  RR7      p V P                  P                  ^8  d<   \         P                  ! V P                  P                  4      V P                  n        V # V P                  P
                  ;'       g    RV P                  n        V # )	z?Sets index names to 'index' for regular, or 'level_x' for Multiindexz-Index name of 'index' is not round-trippable.)
stacklevelc              3  B   "   T F  qP                  R 4      x  K  	  R# 5i)level_N)
startswith).0r   s   & r!   	<genexpr>$set_default_names.<locals>.<genexpr>n   s     !F#Q,,x"8"8#s   TFz<Index names beginning with 'level_' are not round-trippable.)deep)comall_not_noner2   nameslennamewarningswarnr
   r-   copynlevelsfill_missing_names)datanmss   & r!   set_default_namesrG   e   s   
))**jjs8q=TZZ__7MM?+-  X\cc!F#!Fccc!F#!FFFMMN+- 99%9 DzzA11$**2B2BC

 K **//44W

Kr#   c                   V ^8  d   QhRR/# )r   r   dict[str, JSONSerializable]r   )r    s   "r!   r"   r"   }   s      .I r#   c                   V P                   pV P                  f   RpMV P                  pRVR\        V4      /p\        V\        4      '       d/   VP
                  pVP                  pR\        V4      /VR&   WSR&   V# \        V\        4      '       d   VP                  P                  VR&   V# \        V\        4      '       dj   \        P                  ! VP                  4      '       d   RVR	&   V# \        P                  ! VP                  4      p\        V\         4      '       d   WcR	&   V# \        V\"        4      '       d   VP                  VR
&   V# )Nvaluesr?   typeenumconstraintsorderedfreqUTCtzextDtype)dtyper?   r0   r/   r   
categoriesrO   listr   rP   freqstrr   r	   is_utcrR   get_timezoner   r   )arrrT   r?   fieldcatsrO   zones   &      r!   !convert_pandas_type_to_json_fieldr^   }   s0   IIE
xxxx"5)*E
 %)**-- &T
3m"i L 
E;	'	'

**f L 
E?	+	+EHH%%E$K L ))%((3D$$$"d L 
E>	*	*!JJjLr#   c                   V ^8  d   QhRR/# )r   r   zstr | CategoricalDtyper   )r    s   "r!   r"   r"      s     IB IB0F IBr#   c                   V R,          pVR8X  d   V P                  RR4      # VR8X  d   V P                  RR4      # VR8X  d   V P                  RR4      # VR	8X  d   V P                  RR
4      # VR8X  d   R# VR8X  dk   V P                  R4      '       d   RV R,           R2# V P                  R4      '       d.   \        V R,          4      p\        V4      P                  pRV R2# R# VR8X  dW   RV 9   d*   RV 9   d#   \	        V R,          R,          V R,          R7      # RV 9   d   \
        P                  ! V R,          4      # R# \        RV 24      h)a  
Converts a JSON field descriptor into its corresponding NumPy / pandas type

Parameters
----------
field
    A JSON field descriptor

Returns
-------
dtype

Raises
------
ValueError
    If the type of the provided field is unknown or currently unsupported

Examples
--------
>>> convert_json_field_to_pandas_type({"name": "an_int", "type": "integer"})
'int64'

>>> convert_json_field_to_pandas_type(
...     {
...         "name": "a_categorical",
...         "type": "any",
...         "constraints": {"enum": ["a", "b", "c"]},
...         "ordered": True,
...     }
... )
CategoricalDtype(categories=['a', 'b', 'c'], ordered=True, categories_dtype=str)

>>> convert_json_field_to_pandas_type({"name": "a_datetime", "type": "datetime"})
'datetime64[ns]'

>>> convert_json_field_to_pandas_type(
...     {"name": "a_datetime_with_tz", "type": "datetime", "tz": "US/Central"}
... )
'datetime64[ns, US/Central]'
rL   r,   rS   Nr%   int64r'   float64r&   boolr+   timedelta64r)   rR   zdatetime64[ns, ]rP   zperiod[zdatetime64[ns]r-   rN   rO   rM   )rU   rO   objectz#Unsupported or invalid field type: )getr   r   _freqstrr   registryfind
ValueError)r[   typoffsetrP   s   &   r!   !convert_json_field_to_pandas_typern      sM   R -C
hyyT**			yyW--	yyY//			yyV,,	
		
	99T??$U4[M33YYvuV}-Fv&//DTF!$$#	E!i5&8# /7yAQ  5 ==z!233
:3%@
AAr#   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   rE   zDataFrame | Seriesr2   rc   primary_keyzbool | Noneversionr   rI   r   )r    s   "r!   r"   r"      sA     f f
ff f 	f
 !fr#   c                   VRJ d   \        V 4      p / p. pV'       d   V P                  P                  ^8  d|   \        RV P                  4      V n        \	        V P                  P
                  V P                  P                  RR7       F%  w  rg\        V4      pWxR&   VP                  V4       K'  	  M$VP                  \        V P                  4      4       V P                  ^8  d5   V P                  4        F  w  rVP                  \        V
4      4       K!  	  MVP                  \        V 4      4       WTR&   V'       dq   V P                  P                  '       dU   VfQ   V P                  P                  ^8X  d   V P                  P                  .VR&   M"V P                  P                  VR&   MVe   W$R&   V'       d
   \        VR&   V# )a  
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'}
Tr   )strictr?   fields
primaryKeypandas_version)rG   r2   rC   r   ziplevelsr=   r^   appendndimitems	is_uniquer?   TABLE_SCHEMA_VERSION)rE   r2   rp   rq   schemart   levelr?   	new_fieldcolumnss   &&&&       r!   build_table_schemar      se   J } &FF::!lDJJ7DJ"4::#4#4djj6F6FtT=eD	$(&!i(  U
 MM;DJJGHyy1}IFMM;A>? & 	7=>8%%%+*=::"$(JJOO#4F< #'::#3#3F< 		 *|#7 Mr#   c                    V ^8  d   QhRRRR/# )r   precise_floatrc   r   r   r   )r    s   "r!   r"   r"   R  s     @ @D @Y @r#   c                v   \        WR7      pVR,          R,           Uu. uF  q3R,          NK  	  pp\        VR,          VR7      V,          pVR,          R,           Uu/ uF  pVR,          \        V4      bK  	  ppRVP                  4       9   d   \	        R4      h\        R	R
4      ;_uu_ 4        VP                  V4      pRRR4       RVR,          9   d   VP                  VR,          R,          4      p\        VP                  P                  4      ^8X  d/   VP                  P                  R8X  d   RVP                  n        V# VP                  P                   Uu. uF  qwP                  R4      '       d   RMTNK  	  upVP                  n
        V# u upi u upi   + '       g   i     L; iu upi )a  
Builds a DataFrame from a given schema

Parameters
----------
json :
    A JSON table schema
precise_float : bool
    Flag controlling precision when decoding string to double values, as
    dictated by ``read_json``

Returns
-------
df : DataFrame

Raises
------
NotImplementedError
    If the JSON table schema contains either timezone or timedelta data

Notes
-----
    Because :func:`DataFrame.to_json` uses the string 'index' to denote a
    name-less :class:`Index`, this function sets the name of the returned
    :class:`DataFrame` to ``None`` when said string is encountered with a
    normal :class:`Index`. For a :class:`MultiIndex`, the same limitation
    applies to any strings beginning with 'level_'. Therefore, an
    :class:`Index` name of 'index'  and :class:`MultiIndex` names starting
    with 'level_' are not supported.

See Also
--------
build_table_schema : Inverse function.
pandas.read_json
)r   r~   rt   r?   rE   )columnsrd   z<table="orient" can not yet read ISO-formatted Timedelta datazfuture.distinguish_nan_and_naFNru   r2   r5   )r   r   rn   rK   NotImplementedErrorr   astype	set_indexr>   r2   r=   r?   r6   )jsonr   tabler[   	col_orderdfdtypesr   s   &&      r!   parse_table_schemar   R  s}   H :E,1(OH,EF,E5v,EIF	5=)	4Y	?B 8_X..E 	f8??.   '!J
 	
 
7	?	?YYv 
@ uX&\\%/,78rxx~~!#xx}}' $ I @Bxx~~?M!X..A5~BHHN I7 G 
@	?s   FF1F#"#F6#F3	)TNT)4__doc__
__future__r   typingr   r   r   r@   pandas._configr   pandas._libsr   pandas._libs.jsonr   pandas._libs.tslibsr	   pandas.util._exceptionsr
   pandas.core.dtypes.baser   ri   pandas.core.dtypes.commonr   r   r   r   pandas.core.dtypes.dtypesr   r   r   r   pandasr   pandas.core.commoncorecommonr;   pandas.tseries.frequenciesr   pandas._typingr   r   r   pandas.core.indexes.multir   r}   r0   rG   r^   rn   r   r   r   r#   r!   <module>r      s    # 
  )  ) ) 4 9        0
 4  +\0@IBXfR@r#   