
    A>i                       S SK Jr  S SKJrJr  S SKJr  S SKJr  S SKJ	r	J
r
JrJrJrJrJrJr  S SKrS SKrS SKJr  S SKJr  S S	KJrJr  S S
KJr  S SKJr  S SKJ r J!r!  S SK"J#r#  S SK$J%r%  S SK&J'r'J(r(J)r)  S SK*J+r+  S SK,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4  S SK5J6r6  S SK7J8r8  S SK9J:r:J;r;J<r<J=r=J>r>  S SK?J@r@  S SKAJBrBJCrCJDrD  S SKEJFrF  \	(       a.  S SKGJHrHJIrIJJrJ  S SKKJLrL  S SKMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrW  S SKXJYrY  \" S\S   S9rZ\            SE                             SFS  jj5       r[\            SE                             SGS! jj5       r[            SH                             SIS% jjr[ " S& S'\5      r\ " S( S)\\5      r] " S* S+\\5      r^ " S, S-\^5      r_\SSSSSSSSSSSSSSSSS..                                     SJS/ jj5       r`\SSSSSSSSSSSSSSSS0.                                     SKS1 jj5       r`\SSSSSSSSSSSSSSSSS2.                                     SLS3 jj5       r`\SSSSSSSSSSSSSSSSSS4.                                     SMS5 jj5       r`\#" S65      SS7SSS"S"S#SSS8S#SS$SS\R                  S9S4.                                     SNS: jj5       r`\#" S;5       " S< S=\R                  \\Z   5      5       rc " S> S?5      rd " S@ SA\d5      re " SB SC\d5      rf        SOSD jrgg)P    )annotations)ABCabstractmethod)abc)islice)TYPE_CHECKINGAnyGenericLiteralSelfTypeVarfinaloverloadN)option_context)lib)ujson_dumpsujson_loads)iNaT)import_optional_dependency)AbstractMethodErrorOutOfBoundsDatetime)
set_module)check_dtype_backend)
ensure_stris_string_dtypepandas_dtype)PeriodDtype)
ArrowDtype	DataFrameIndex
MultiIndexSeriesisnanotnato_datetime)concat)arrow_table_to_pandas)	IOHandlesdedup_names
get_handleis_potential_multi_indexstringify_path)convert_to_line_delimits)build_table_schemaparse_table_schemaset_default_names)validate_integer)CallableHashableMapping)TracebackType)
CompressionOptionsDtypeArgDtypeBackendFilePath
IndexLabel
JSONEngineJSONSerializable
ReadBufferStorageOptionsWriteBuffer)NDFrameFrameSeriesStrT)frameseries)bound.c                    g N path_or_bufobjorientdate_formatdouble_precisionforce_ascii	date_unitdefault_handlerlinescompressionindexindentstorage_optionsmodes                 S/var/www/html/land-tabula/venv/lib/python3.13/site-packages/pandas/io/json/_json.pyto_jsonrX   e   s          c                    g rF   rG   rH   s                 rW   rX   rX   x   s      rY   TFinferc                   US;   a  U
SL a  [        S5      eUS;   a  U
SL a  [        S5      eU
c  Sn
U(       a  US:w  a  [        S5      eUS	;  a  S
U S3n[        U5      eUS:X  a  U(       a  US:w  a  Sn[        U5      eUS:X  a7  [        U[        5      (       a"  UR                  UR                  =(       d    SS9nUS:X  Gad  US;  a  [        SU S35      e[        U[
        5      (       Gaz  Sn[        R                  " UR                  R                  S 5      5      S   n[        U5      (       aV  UR                  SS9nSnU H?  nUR                  UUR                  S S 2U4   R                  R                  U5      5        MA     UR                   R"                  R$                  S;   aK  U(       d  UR                  SS9nSn[        UR                   5      R                  R                  U5      Ul        UR&                  R"                  R$                  S;   aK  U(       d  UR                  SS9nSn[        UR&                  5      R                  R                  U5      Ul        O[        U[        5      (       a  UR"                  R$                  S;   a*  UR                  SS9nUR                  R                  U5      nUR                   R"                  R$                  S;   aB  UR                  SS9n[        UR                   5      R                  R                  U5      Ul        US:X  a  [        U[
        5      (       a  [(        nOC[        U[        5      (       a  [*        nO'[        U[
        5      (       a  [,        nO[/        S5      eU" UUUUUUUU
US9	R1                  5       nU(       a  [3        U5      nU b/  [5        XXS9 nUR6                  R1                  U5        S S S 5        g U$ ! , (       d  f       g = f)N)recordsvaluesTzT'index=True' is only valid when 'orient' is 'split', 'table', 'index', or 'columns'.rS   columnsFzV'index=False' is only valid when 'orient' is 'split', 'table', 'records', or 'values'.r]   z3'lines' keyword only valid when 'orient' is records)awzmode=z@ is not a valid option.Only 'w' and 'a' are currently supported.ra   zNmode='a' (append) is only supported when lines is True and orient is 'records'tabler^   )nameepochsmsusnszInvalid value 'z' for option 'date_unit'c                     U R                   S;   $ )N)Mm)kind)dts    rW   <lambda>to_json.<locals>.<lambda>   s    :8MrY   r   deepMmz''obj' should be a Series or a DataFrame)rK   rL   rM   ensure_asciirO   rP   rS   rT   )rR   rU   )
ValueError
isinstancer"   to_framerd   r   npnonzerodtypesmaplencopyisetitemilocro   as_unitrS   dtypern   r`   JSONTableWriterSeriesWriterFrameWriterNotImplementedErrorwriter-   r*   handle)rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   msgcopiedcolscolwriterrg   handless                        rW   rX   rX      s     &&5D=%
 	
 
'	'EUN&
 	
 
9$NOO:D6 8 8 	 os{EVy%84 	 oZV44ll 4Hl5g 33yk9QRSSc9%%F::cjjnn-MNOPQRD4yyhhEh*CLLchhq#v&6&9&9&A&A)&LM  yy##t+(((.C!F"399-0088C	{{  %%-(((.C!F$S[[144<<YGV$$yy~~%hhEh*ffnnY/yy##t+hhEh*"399-0088C	 ZY77 	C	 	 	C	#	#!"KLL) '
	 eg  $Q';
NN  #
  
 
 s   	O00
O>c                      \ rS rSr% S\S'     S
                   SS jjrSS jrSS jr\\	SS j5       5       r
S	rg)Writeri  str_default_orientNc
                    Xl         Uc  U R                  nX l        X0l        X@l        XPl        X`l        Xl        Xpl        Xl	        U R                  5         g rF   )rJ   r   rK   rL   rM   ru   rO   rP   rS   rT   _format_axes)
selfrJ   rK   rL   rM   ru   rO   rS   rP   rT   s
             rW   __init__Writer.__init__  sQ     >))F& 0(".
rY   c                    [        U 5      erF   r   r   s    rW   r   Writer._format_axes      !$''rY   c                    U R                   S:H  n[        U R                  U R                  U R                  U R
                  U R                  UU R                  U R                  S9$ )Niso)rK   rM   ru   rO   	iso_datesrP   rT   )	rL   r   obj_to_writerK   rM   ru   rO   rP   rT   )r   r   s     rW   r   Writer.write"  s[    $$-	;;!22**nn 00;;	
 		
rY   c                    g)zObject to write in JSON format.NrG   r   s    rW   r   Writer.obj_to_write/  s    rY   )	rL   rO   rP   rM   ru   rT   rS   rJ   rK   Nr   )rJ   r@   rK   
str | NonerL   r   rM   intru   boolrO   r   rS   r   rP   (Callable[[Any], JSONSerializable] | NonerT   r   returnNoner   r   r   r   r   z"NDFrame | Mapping[IndexLabel, Any])__name__
__module____qualname____firstlineno____annotations__r   r   r   propertyr   r   __static_attributes__rG   rY   rW   r   r     s     EI  	
     B  
6(
 .  .rY   r   c                  6    \ rS rSrSr\SS j5       rSS jrSrg)	r   i5  rS   c                    U R                   (       d=  U R                  S:X  a-  U R                  R                  U R                  R                  S.$ U R                  $ )Nsplit)rd   data)rS   rK   rJ   rd   r^   r   s    rW   r   SeriesWriter.obj_to_write8  s8    zzdkkW4 HHMM488??CC88OrY   c                    U R                   R                  R                  (       d*  U R                  S:X  a  [	        SU R                   S35      eg g )NrS   z(Series index must be unique for orient='')rJ   rS   	is_uniquerK   rv   r   s    rW   r   SeriesWriter._format_axes?  sA    xx~~''DKK7,BG}TUVWW -C'rY   rG   Nr   r   	r   r   r   r   r   r   r   r   r   rG   rY   rW   r   r   5  s    O XrY   r   c                  6    \ rS rSrSr\SS j5       rSS jrSrg)	r   iD  r`   c                    U R                   (       d.  U R                  S:X  a  U R                  R                  SS9nUS	 U$ U R                  nU$ )Nr   )rK   rS   )rS   rK   rJ   to_dict)r   r   s     rW   r   FrameWriter.obj_to_writeG  sL    zzdkkW488++7+;LW%   88LrY   c                >   U R                   R                  R                  (       d)  U R                  S;   a  [	        SU R                   S35      eU R                   R
                  R                  (       d*  U R                  S;   a  [	        SU R                   S35      egg)z*
Try to format axes if they are datelike.
r_   z+DataFrame index must be unique for orient='z'.)rS   r`   r]   z-DataFrame columns must be unique for orient='N)rJ   rS   r   rK   rv   r`   r   s    rW   r   FrameWriter._format_axesP  s     xx~~''DKK;O,O=dkk]"M  xx))dkk >
 /

 ?}BO /
)rY   rG   Nr   r   r   rG   rY   rW   r   r   D  s    O rY   r   c                  n   ^  \ rS rSrSr  S                 SU 4S jjjr\SS j5       rSrU =r	$ )	r   ib  r]   c
                H  > [         TU ]  UUUUUUUUU	S9	  US:w  a  SU S3n
[        U
5      e[        XR                  S9U l        U R                  (       a  [        U5      nUR                  S:X  a*  [        UR                  [        5      (       a  [        S5      eUR                  S:X  a-  UR                  [        UR                  R                  5      ;   d=  [        UR                  R!                  UR                  R                  5      5      (       a  S	n
[        U
5      eUR#                  S
/S9R                  nSn[        U5      (       a(  UR%                  5       nSnX   R'                  S 5      X'   U R                  (       d  UR)                  SS9U l        Or[        UR                  R,                  [.        5      (       a5  U(       d  UR%                  SS9nUR                  R1                  5       Ul        UR)                  SS9U l        SU l        SU l        Xpl        g)z
Adds a `schema` attribute with the Table Schema, resets
the index (can't do in caller, because the schema inference needs
to know what the index is, forces orient to records, and forces
date_format to 'iso'.
)rP   rT   r   z8Trying to write with `orient='table'` and `date_format='zH'`. Table Schema requires dates to be formatted with `date_format='iso'`)rS      z6orient='table' is not supported for MultiIndex columns   z/Overlapping names between the index and columns	timedelta)includeFTc                "    U R                  5       $ rF   )	isoformat)xs    rW   rp   *JSONTableWriter.__init__.<locals>.<lambda>  s
    AKKMrY   )droprr   r]   N)superr   rv   r.   rS   schemar0   ndimrw   r`   r!   r   rd   setnamesr}   intersectionselect_dtypesr~   r|   reset_indexrJ   r   r   to_timestamprL   rK   )r   rJ   rK   rL   rM   ru   rO   rS   rP   rT   r   
timedeltasr   	__class__s                rW   r   JSONTableWriter.__init__e  s   $ 	+ 	 
	
 %!!, .;; 
 S/!(JJ?::#C(C 88q=ZZ@@%H 
 XX]S-A!AsKK$$SYY__5H
 H
 DCS/!&&}&=EE
z??((*CF!o112IJCO zzD1DH #))//;77(((.CII224	E2DH 
rY   c                4    U R                   U R                  S.$ )N)r   r   )r   rJ   r   s    rW   r   JSONTableWriter.obj_to_write  s    ++txx88rY   )rL   rS   rJ   rK   r   r   )rK   r   rL   r   rM   r   ru   r   rO   r   rS   r   rP   r   rT   r   r   r   r   )
r   r   r   r   r   r   r   r   r   __classcell__)r   s   @rW   r   r   b  s    O EIJ J 	J
 J J J J BJ J 
J JX 9 9rY   r   )rK   typr   convert_axesconvert_dateskeep_default_datesprecise_floatrO   encodingencoding_errorsrQ   rR   nrowsrU   dtype_backendenginec                   g rF   rG   rI   rK   r   r   r   r   r   r   rO   r   r   rQ   	chunksizerR   r   rU   r   r   s                     rW   	read_jsonr     s    * $'rY   )rK   r   r   r   r   r   rO   r   r   rQ   rR   r   rU   r   r   c                   g rF   rG   r   s                     rW   r   r     s    * %(rY   )rK   r   r   r   r   r   rO   r   r   rQ   r   rR   r   rU   r   r   c                   g rF   rG   r   s                     rW   r   r     s    * rY   )rK   r   r   r   r   r   r   rO   r   r   rQ   r   rR   r   rU   r   r   c                   g rF   rG   r   s                     rW   r   r     s    * rY   pandasrB   strictujsonc               P   US:X  a  U(       a  [        S5      eUS:X  a  U(       a  [        S5      e[        U5        Uc  US:w  a  SnUc  US:w  a  Sn[        U 40 SU_SU_SU_SU_S	U_S
U_SU_SU_SU	_SU_SU_SU_SU_SU_SU
_SU_SU_6nU(       a  U$ UR                  5       $ )a&  
Convert a JSON string to pandas object.

This method reads JSON files or JSON-like data and converts them into pandas
objects. It supports a variety of input formats, including line-delimited JSON,
compressed files, and various data representations (table, records, index-based,
etc.). When `chunksize` is specified, an iterator is returned instead of loading
the entire data into memory.

Parameters
----------
path_or_buf : a str path, path object or file-like object
    Any valid string path is acceptable. The string could be a URL. Valid
    URL schemes include http, ftp, s3, and file. For file URLs, a host is
    expected. A local file could be:
    ``file://localhost/path/to/table.json``.

    If you want to pass in a path object, pandas accepts any
    ``os.PathLike``.

    By file-like object, we refer to objects with a ``read()`` method,
    such as a file handle (e.g. via builtin ``open`` function)
    or ``StringIO``.

orient : str, optional
    Indication of expected JSON string format.
    Compatible JSON strings can be produced by ``to_json()`` with a
    corresponding orient value.
    The set of possible orients is:

    - ``'split'`` : dict like
      ``{{index -> [index], columns -> [columns], data -> [values]}}``
    - ``'records'`` : list like
      ``[{{column -> value}}, ... , {{column -> value}}]``
    - ``'index'`` : dict like ``{{index -> {{column -> value}}}}``
    - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}``
    - ``'values'`` : just the values array
    - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}``

    The allowed and default values depend on the value
    of the `typ` parameter.

    * when ``typ == 'series'``,

      - allowed orients are ``{{'split','records','index'}}``
      - default is ``'index'``
      - The Series index must be unique for orient ``'index'``.

    * when ``typ == 'frame'``,

      - allowed orients are ``{{'split','records','index',
        'columns','values', 'table'}}``
      - default is ``'columns'``
      - The DataFrame index must be unique for orients ``'index'`` and
        ``'columns'``.
      - The DataFrame columns must be unique for orients ``'index'``,
        ``'columns'``, and ``'records'``.

typ : {{'frame', 'series'}}, default 'frame'
    The type of object to recover.

dtype : bool or dict, default None
    If True, infer dtypes; if a dict of column to dtype, then use those;
    if False, then don't infer dtypes at all, applies only to the data.

    For all ``orient`` values except ``'table'``, default is True.

convert_axes : bool, default None
    Try to convert the axes to the proper dtypes.

    For all ``orient`` values except ``'table'``, default is True.

convert_dates : bool or list of str, default True
    If True then default datelike columns may be converted (depending on
    keep_default_dates).
    If False, no dates will be converted.
    If a list of column names, then those columns will be converted and
    default datelike columns may also be converted (depending on
    keep_default_dates).

keep_default_dates : bool, default True
    If parsing dates (convert_dates is not False), then try to parse the
    default datelike columns.
    A column label is datelike if

    * it ends with ``'_at'``,

    * it ends with ``'_time'``,

    * it begins with ``'timestamp'``,

    * it is ``'modified'``, or

    * it is ``'date'``.

precise_float : bool, default False
    Set to enable usage of higher precision (strtod) function when
    decoding string to double values. Default (False) is to use fast but
    less precise builtin functionality.

date_unit : str, default None
    The timestamp unit to detect if converting dates. The default behaviour
    is to try and detect the correct precision, but if this is not desired
    then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds,
    milliseconds, microseconds or nanoseconds respectively.

encoding : str, default is 'utf-8'
    The encoding to use to decode py3 bytes.

encoding_errors : str, optional, default "strict"
    How encoding errors are treated. `List of possible values
    <https://docs.python.org/3/library/codecs.html#error-handlers>`_ .

lines : bool, default False
    Read the file as a json object per line.

chunksize : int, optional
    Return JsonReader object for iteration.
    See the `line-delimited json docs
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#line-delimited-json>`_
    for more information on ``chunksize``.
    This can only be passed if `lines=True`.
    If this is None, the file will be read into memory all at once.

compression : str or dict, default 'infer'
    For on-the-fly decompression of on-disk data. If 'infer' and 'path_or_buf' is
    path-like, then detect compression from the following extensions: '.gz',
    '.bz2', '.zip', '.xz', '.zst', '.tar', '.tar.gz', '.tar.xz' or '.tar.bz2'
    (otherwise no compression).
    If using 'zip' or 'tar', the ZIP file must contain only one data file to be
    read in.
    Set to ``None`` for no decompression.
    Can also be a dict with key ``'method'`` set
    to one of {``'zip'``, ``'gzip'``, ``'bz2'``, ``'zstd'``, ``'xz'``, ``'tar'``}
    and other key-value pairs are forwarded to
    ``zipfile.ZipFile``, ``gzip.GzipFile``,
    ``bz2.BZ2File``, ``zstandard.ZstdDecompressor``, ``lzma.LZMAFile`` or
    ``tarfile.TarFile``, respectively.
    As an example, the following could be passed for Zstandard decompression using a
    custom compression dictionary:
    ``compression={'method': 'zstd', 'dict_data': my_compression_dict}``.

nrows : int, optional
    The number of lines from the line-delimited jsonfile that has to be read.
    This can only be passed if `lines=True`.
    If this is None, all the rows will be returned.

storage_options : dict, optional
    Extra options that make sense for a particular storage connection, e.g.
    host, port, username, password, etc. For HTTP(S) URLs the key-value pairs
    are forwarded to ``urllib.request.Request`` as header options. For other
    URLs (e.g. starting with "s3://", and "gcs://") the key-value pairs are
    forwarded to ``fsspec.open``. Please see ``fsspec`` and ``urllib`` for more
    details, and for more examples on storage options refer `here
    <https://pandas.pydata.org/docs/user_guide/io.html?
    highlight=storage_options#reading-writing-remote-files>`_.

dtype_backend : {{'numpy_nullable', 'pyarrow'}}
    Back-end data type applied to the resultant :class:`DataFrame`
    (still experimental). If not specified, the default behavior
    is to not use nullable data types. If specified, the behavior
    is as follows:

    * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
    * ``"pyarrow"``: returns pyarrow-backed nullable
      :class:`ArrowDtype` :class:`DataFrame`

    .. versionadded:: 2.0

engine : {{"ujson", "pyarrow"}}, default "ujson"
    Parser engine to use. The ``"pyarrow"`` engine is only available when
    ``lines=True``.

    .. versionadded:: 2.0

Returns
-------
Series, DataFrame, or pandas.api.typing.JsonReader
    A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``.
    Otherwise, the type returned depends on the value of ``typ``.

See Also
--------
DataFrame.to_json : Convert a DataFrame to a JSON string.
Series.to_json : Convert a Series to a JSON string.
json_normalize : Normalize semi-structured JSON data into a flat table.

Notes
-----
Specific to ``orient='table'``, if a :class:`DataFrame` with a literal
:class:`Index` name of `index` gets written with :func:`to_json`, the
subsequent read operation will incorrectly set the :class:`Index` name to
``None``. This is because `index` is also used by :func:`DataFrame.to_json`
to denote a missing :class:`Index` name, and the subsequent
:func:`read_json` operation cannot distinguish between the two. The same
limitation is encountered with a :class:`MultiIndex` and any names
beginning with ``'level_'``.

Examples
--------
>>> from io import StringIO
>>> df = pd.DataFrame(
...     [["a", "b"], ["c", "d"]],
...     index=["row 1", "row 2"],
...     columns=["col 1", "col 2"],
... )

Encoding/decoding a Dataframe using ``'split'`` formatted JSON:

>>> df.to_json(orient="split")
'{"columns":["col 1","col 2"],"index":["row 1","row 2"],"data":[["a","b"],["c","d"]]}'

>>> pd.read_json(StringIO(_), orient="split")  # noqa: F821
      col 1 col 2
row 1     a     b
row 2     c     d

Encoding/decoding a Dataframe using ``'index'`` formatted JSON:

>>> df.to_json(orient="index")
'{"row 1":{"col 1":"a","col 2":"b"},"row 2":{"col 1":"c","col 2":"d"}}'

>>> pd.read_json(StringIO(_), orient="index")  # noqa: F821
      col 1 col 2
row 1     a     b
row 2     c     d

Encoding/decoding a Dataframe using ``'records'`` formatted JSON.
Note that index labels are not preserved with this encoding.

>>> df.to_json(orient="records")
'[{"col 1":"a","col 2":"b"},{"col 1":"c","col 2":"d"}]'

>>> pd.read_json(StringIO(_), orient="records")  # noqa: F821
  col 1 col 2
0     a     b
1     c     d

Encoding with Table Schema

>>> df.to_json(orient="table")
'{"schema":{"fields":[{"name":"index","type":"string","extDtype":"str"},{"name":"col 1","type":"string","extDtype":"str"},{"name":"col 2","type":"string","extDtype":"str"}],"primaryKey":["index"],"pandas_version":"1.4.0"},"data":[{"index":"row 1","col 1":"a","col 2":"b"},{"index":"row 2","col 1":"c","col 2":"d"}]}'

The following example uses ``dtype_backend="numpy_nullable"``

>>> data = '''{"index": {"0": 0, "1": 1},
...        "a": {"0": 1, "1": null},
...        "b": {"0": 2.5, "1": 4.5},
...        "c": {"0": true, "1": false},
...        "d": {"0": "a", "1": "b"},
...        "e": {"0": 1577.2, "1": 1577.1}}'''
>>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable")
   index     a    b      c  d       e
0      0     1  2.5   True  a  1577.2
1      1  <NA>  4.5  False  b  1577.1
rc   z)cannot pass both dtype and orient='table'z0cannot pass both convert_axes and orient='table'TrK   r   r   r   r   r   r   rO   r   rQ   r   rR   r   rU   r   r   r   )rv   r   
JsonReaderread)rI   rK   r   r   r   r   r   r   rO   r   r   rQ   r   rR   r   rU   r   r   json_readers                      rW   r   r     s-   l UDEE\KLL&}7* ' 1  	
 " $ . $        (  (!" $#$ %K* !!rY   zpandas.api.typingc                  n   \ rS rSrSrSS\R                  S4                         SS jjrS rSS jr	\
SS	 j5       r\
SS
 j5       r\
SS j5       rSS jrSS jrSS jrS S jrS!S jrS"S jr\
SS j5       r\
SS j5       r\
    SS j5       rSS jrS"S jr        S#S jrSrg)$r   iX  z
JsonReader provides an interface for reading in a JSON file.

If initialized with ``lines=True`` and ``chunksize``, can be iterated over
``chunksize`` lines at a time. Otherwise, calling ``read`` reads in the
whole document.
Nr   r   c                   X l         X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl        UU l	        Xl
        Xl        Xl        Xl        SU l        Xl        UU l        S U l        UU l        U R                  S;  a  ['        SU R                   S35      eU R                  bS  [)        SU R                  S5      U l        U R                  (       d  ['        S5      eU R                  S:X  a  ['        S	5      eU R                  b8  [)        S
U R                  S5      U l        U R                  (       d  ['        S5      eU R                  S:X  a#  U R                  (       d  ['        S5      eXl        g U R                  S:X  a\  U R-                  U5      nU R                  (       d2  U R                  (       d!  U    UR/                  5       U l        S S S 5        g UU l        g g ! , (       d  f       g = f)Nr   >   r   pyarrowzThe engine type z is currently not supported.r   r   z*chunksize can only be passed if lines=Truer   z<currently pyarrow engine doesn't support chunksize parameterr   z&nrows can only be passed if lines=TruezEcurrently pyarrow engine only supports the line-delimited JSON formatr   )rK   r   r   r   r   r   r   rO   r   r   rR   rU   rQ   r   
nrows_seenr   r   r   r   rv   r1   r   _get_data_from_filepathr   )r   filepath_or_bufferrK   r   r   r   r   r   r   rO   r   rQ   r   rR   r   rU   r   r   r   r   s                       rW   r   JsonReader.__init__b  s   * 
(*"4*" &.
"
..2*;;22"4;;-/KL  >>%-k4>>1MDN:: !MNN{{i' R  ::!)'4::qADJ:: !IJJ;;)#:: 5  +I[[G#//0BCD NNdjj $		DI T !	 $
 Ts   >G&&
G4c           	        [        U5      n [        USU R                  U R                  U R                  U R
                  S9U l        U R                  R                  nU$ ! [         a  n[        SU S35      UeSnAff = f)z
The function read_json accepts three input types:
    1. filepath (string-like)
    2. file-like object (e.g. open file object, StringIO)
r)r   rR   rU   errorszFile z does not existN)
r,   r*   r   rR   rU   r   r   OSErrorFileNotFoundErrorr   )r   r   errs      rW   r   "JsonReader._get_data_from_filepath  s     ,,>?	%" ,, $ 4 4++DL "\\00!!  	#*+?;	s   ;A   
A?*A::A?c                v    SSR                  S U 5        Vs/ s H  o"(       d  M  UPM     sn5       S3$ s  snf )z7
Combines a list of JSON objects into one JSON object.
[,c              3  @   #    U  H  oR                  5       v   M     g 7frF   )strip).0lines     rW   	<genexpr>,JsonReader._combine_lines.<locals>.<genexpr>  s     +KUTJJLLUs   ])join)r   rQ   r  s      rW   _combine_linesJsonReader._combine_lines  s<    
 +KU+KT+K4t$+KTUVVWX	
Ts   
6
6
c                    g rF   rG   r   s    rW   r   JsonReader.read  s    ?BrY   c                    g rF   rG   r   s    rW   r   r    s    =@rY   c                    g rF   rG   r   s    rW   r   r    s    RUrY   c                    U    U R                   S:X  a  U R                  5       nO U R                   S:X  a  U R                  5       nSSS5        W$ ! , (       d  f       W$ = f)z1
Read the whole JSON input into a pandas object.
r   r   N)r   _read_pyarrow_read_ujsonr   rJ   s     rW   r   r    sV    
 {{i'((*'&&(	  
 T 
s   AA
Ac                   [        S5      nSn[        U R                  [        5      (       a  [        S5      n/ nU R                  R	                  5        HC  u  pV[        U5      n[        U[        5      (       d  M'  UR                  XWR                  45        ME     UR                  U5      nUR                  USS9nUR                  U R                  US9n	[        XR                  S9n
U
$ )z%
Read JSON using the pyarrow engine.
zpyarrow.jsonNr   r[   )explicit_schemaunexpected_field_behavior)parse_options)r   )r   rw   r   dictitemsr   r   appendpyarrow_dtyper   ParseOptionsr   r   r'   r   )r   pyarrow_jsonoptionspafieldsfieldr   pd_dtyper   pa_tabledfs              rW   r  JsonReader._read_pyarrow  s     2.Adjj$''+I6BF $

 0 0 2'.h
33MM5*@*@"AB !3
 YYv&F"// &' 0 G  ))$))7)K"8;M;MN	rY   c                   U R                   (       a  U R                  (       a  [        U 5      nOU R                  (       aL  [	        [        U R                  U R                  5      5      nU R                  U5      nU R                  U5      nOb[        U R                  5      nUR                  S5      nU R                  U R                  U5      5      nOU R                  U R                  5      nU R                  [        R                  La0  [        SS5         UR                  SU R                  S9sSSS5        $ U$ ! , (       d  f       g= f)z#
Read JSON using the ujson engine.

future.distinguish_nan_and_naFinfer_objectsr   N)rQ   r   r&   r   listr   r   r  _get_object_parserr   r   r   r   
no_defaultr   convert_dtypes)r   rJ   rQ   
lines_jsonr   
data_liness         rW   r  JsonReader._read_ujson  s    
 ::~~TlVDIItzz:;!007
--j9!$)),!ZZ-
--d.A.A*.MN))$))4CS^^3 ?G))"'t7I7I *  HG
 J HGs   D==
Ec           	        U R                   nU R                  nU R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  S.nUS:X  a  [        U40 UD6R                  5       $ US:X  a3  [        U[        5      (       d  X4S'   [        U40 UD6R                  5       $ [        SU< S35      e)z.
Parses a json document into a pandas object.
)rK   r   r   r   r   r   rO   r   rB   rC   r   ztyp=z must be 'frame' or 'series'.)r   r   rK   r   r   r   r   rO   r   FrameParserparserw   r   SeriesParserrv   )r   jsonr   r   kwargss        rW   r2  JsonReader._get_object_parser  s     hh

kkZZ --!//"&"9"9!//!//	
 '>t.v.4466H_eT**"'w//5577v%BCDDrY   c                T    U R                   b  U R                   R                  5         gg)z
If we opened a stream earlier, in _get_data_from_filepath, we should
close it.

If an open stream or file was passed, we leave it open.
N)r   closer   s    rW   r@  JsonReader.close-  s#     <<#LL  $rY   c                    U $ rF   rG   r   s    rW   __iter__JsonReader.__iter__7      rY   c                    g rF   rG   r   s    rW   __next__JsonReader.__next__:  s    CFrY   c                    g rF   rG   r   s    rW   rG  rH  =  s    ADrY   c                    g rF   rG   r   s    rW   rG  rH  @  s     !rY   c                   U R                   (       a0  U R                  U R                   :  a  U R                  5         [        e[	        [        U R                  U R                  5      5      nU(       d  U R                  5         [        e U R                  U5      nU R                  U5      n[        U R                  U R                  [        U5      -   5      Ul        U =R                  [        U5      -  sl        U R                  [        R                   La0  [#        SS5         UR%                  SU R                  S9sS S S 5        $ U$ ! [         a  nU R                  5         UeS nAff = f! , (       d  f       g = f)Nr.  Fr/  )r   r   r@  StopIterationr1  r   r   r   r  r2  ranger}   rS   	Exceptionr   r   r3  r   r4  )r   rQ   r5  rJ   exs        rW   rG  rH  E  s!   ::$//TZZ7JJLVDIIt~~67JJL		,,U3J))*5C dootS/IJCIOOs3x'O
 S^^3 ?G))"'t7I7I *  HG
 J  	JJLH	
 HGs%   	A1E	 #E-	
E*E%%E*-
E;c                    U $ rF   rG   r   s    rW   	__enter__JsonReader.__enter__b  rE  rY   c                $    U R                  5         g rF   )r@  )r   exc_type	exc_value	tracebacks       rW   __exit__JsonReader.__exit__e  s     	

rY   )r   rR   r   r   r   rO   r   r   r   r   r   r   r   rQ   r   r   rK   r   rU   r   )r   rA   r   bool | Noner   r   r   r   rQ   r   r   
int | NonerR   r6   r   rZ  rU   StorageOptions | Noner   r   r   DtypeBackend | lib.NoDefaultr   r;   r   r   r   )r   JsonReader[Literal['frame']]r   r   )r   JsonReader[Literal['series']]r   r"   )r   z&JsonReader[Literal['frame', 'series']]r   DataFrame | Seriesr   r_  r   r   )r<  r   r   r_  r   )r   r   )rT  ztype[BaseException] | NonerU  zBaseException | NonerV  zTracebackType | Noner   r   )r   r   r   r   __doc__r   r3  r   r   r  r   r   r  r  r2  r@  rC  rG  rQ  rW  r   rG   rY   rW   r   r   X  sy   0 26&.69nn$'H! 	H! "H! !H! H! H! H! (H! H!  /!H!" $#H!$ 4%H!& 'H!( 
)H!T".
 B B@ @U U24E2! F FD D!4!	! !:, ( (	
 
rY   r   c                  (   \ rS rSr% S\S'   S\S'   SrSSS	S
S.rS\S'   SSSSSS\R                  4               SS jjr	\
SS j5       r\
SS j5       rSS jr\
SS j5       rS r\
   S           SS jj5       r\
SS j5       rSrg)Parserin  ztuple[str, ...]_split_keysr   r   rf   i3l    ,b/ l    `'rl     F[L'r<  NTFc
                T   Xl         Uc  U R                  nX l        X0l        UbL  UR	                  5       nXR
                  ;  a  [        SU R
                   35      eU R                  U   U l        OU R                  S   U l        Xpl	        X@l
        XPl        Xl        X`l        Xl        g )Nzdate_unit must be one of rg   )r<  r   rK   r   lower_STAMP_UNITSrv   _MIN_STAMPS	min_stampr   r   r   rO   r   r   )
r   r<  rK   r   r   r   r   r   rO   r   s
             rW   r   Parser.__init__{  s     	>))F
 !)I 1 11 #<T=N=N<O!PQQ!--i8DN!--c2DN*(*""4*rY   c                    [        UR                  5       5      R                  [        U R                  5      5      nU(       a  SR	                  U5      n[        SU 35      eg)zD
Checks that dict has only the appropriate keys for orient='split'.
z, z!JSON data had unexpected key(s): N)r   keys
differencere  r  rv   )r   decodedbad_keysbad_keys_joineds       rW   check_keys_splitParser.check_keys_split  sT    
 w||~&11#d6F6F2GH"ii1O@@QRSS rY   c                    U R                  5       nU R                  (       a  U R                  U5      nU R                  U5      nU$ rF   )_parser   _convert_axes_try_convert_typesr  s     rW   r:  Parser.parse  s;    kkm$$S)C%%c*
rY   c                    [        U 5      erF   r   r   s    rW   ru  Parser._parse  r   rY   c           	         UR                    Hf  nUR                  U5      n[        X3R                  SS9nU R	                  UUSSSS9u  pVU(       d  MF  [        XUR                  SS9n[        XU5        Mh     U$ )z
Try to convert axes.
F)r   r~   T)rd   r   
use_dtypesr   is_axis)_AXIS_ORDERS	_get_axisr"   r   _try_convert_datar    setattr)r   rJ   	axis_nameaxsernew_serresultnew_axiss           rW   rv  Parser._convert_axes  s    
 ))Iy)B88%8C"44 " 5 OG v EJ1 * 
rY   c                    [        U 5      erF   r   r  s     rW   rw  Parser._try_convert_types  r   rY   c                ~   UnU(       a  U R                   (       d@  [        [        U5      5      (       a  US4$ UR                  [        R
                  5      nUS4$ U R                   SL a  Ox[        X@R                  U5      (       d]  [        U R                   [        5      (       a  U R                   R                  U5      OU R                   nUb   UR                  U5      S4$ U(       a  U R                  U5      n	XLa  U	S4$ Sn
U R                  [         R"                  La  U(       d  US4$ [%        UR                   5      (       a   UR                  S5      nSn
UR                   R&                  S:X  a$  UR                   S:w  a   UR                  S5      nSn
[)        U5      (       a=  UR                   S;   a-   UR                  S5      n	X:H  R                  5       (       a  U	nSn
UR                   S:X  a$  UR                   S:w  a   UR                  S5      nSn
US:X  a$  [)        U5      (       a  U R,                  S	:X  a  US4$ X*4$ ! [        [        4 a    US4s $ f = f! [        [        4 a     GNf = f! [        [        4 a     Nf = f! [        [        [*        4 a     Nf = f! [        [        4 a     Nf = f)
z9
Try to parse a Series into a column by inferring dtype.
FTfloat64f)floatobjectint64r   rS   r   )r   allr$   fillnary   nan_should_convert_datesr   rw   r  getastype	TypeErrorrv   _try_convert_to_dater   r   r3  r   rn   r}   OverflowErrorrK   )r   rd   r   r|  r   r}  org_datafilledr   new_data	converteds              rW   r  Parser._try_convert_data  s    ::uT{##;&RVV,t|#t#*66 
 -7tzz4,H,HDJJNN4(djj  $+#{{51477 006H#~%	S^^3G:TZZ(({{9- 	 ::??c!djjI&={{9- 	
 t99'::#??73$))++#D $I ::4::#8{{7+ 	
 7?s4yy{{g%U{"i &z2 +#U{*+" z*  z*  z=9  z* sZ   I I! I8 :,J J) II!I54I58J
JJ&%J&)J<;J<c                   [        U5      (       d  U$ UnUR                  S:X  d  UR                  S:X  a   UR                  S5      n[        UR                  R                  [        R                  5      (       aO  [        UR                  5      X R                  :  -  UR                  [        :H  -  nUR                  5       (       d  U$ UR                  S:X  aY  [        R                   " 5          [        R"                  " S[$        5        S H  n ['        USUS9s  sSSS5        $    SSS5        U$ U R*                  (       a  U R*                  4OU R,                  nU H+  n ['        USUS	9nUR.                  R1                  S
5      n  U$    U$ ! [         a    Us $ [        [
        4 a     GNhf = f! [(         a     M  f = f! , (       d  f       U$ = f! [2         a     M  [
        [        [        4 a     M  f = f)z
Try to parse an ndarray like into a date column.

Try to coerce object in epoch/iso formats and integer/float in epoch
formats.
r  stringr  ignore)Niso8601mixedraise)r   formatN)r   unitrj   )r}   r   r  r  r  rv   
issubclasstypery   numberr#   _valuesrj  r   r  warningscatch_warningssimplefilterUserWarningr%   rN  rO   rh  ro   r   r   )r   r   r  in_ranger  
date_unitsrO   _s           rW   r  Parser._try_convert_to_date%  s    4yyK>>X%8)C;;w/ hnn))29955X%%&nn,.##t+- 
 <<>>>>X%((* %%h<8F*8GFSS +* 9	 +2  /3nn$..*$BSBSJ'	
 'xiPD-A
  ( S ! z* * %  +*2 	 + "M9= se   F .!G
F3G&G"&GF0F0/F03
G=G GG
G
G;#G;:G;)
r   r   rO   r   r   r<  r   rj  rK   r   )r<  r   r   DtypeArg | Noner   r   r   bool | list[str]r   r   r   r   r   r\  r   r   )ro  r  r   r   r`  )rJ   r_  r   r_  )TTF)rd   r3   r   r"   r|  r   r   r  r}  r   r   ztuple[Series, bool])r   r"   r   r"   )r   r   r   r   r   rh  ri  r   r3  r   r   rr  r:  ru  rv  rw  r  r  r   rG   rY   rW   rd  rd  n  sZ     *L	K I "&!*.#(#69nn"+"+ 	"+
 "+ ("+ !"+ "+ 4"+ 
"+H T T  (  &( 
  *.VV V 	V
 (V V 
V Vp 9 9rY   rd  c                  0    \ rS rSrSrSrSS jrS	S jrSrg)
r;  ib  rS   )rd   rS   r   c                   [        U R                  U R                  S9nU R                  S:X  aJ  UR	                  5        VVs0 s H  u  p#[        U5      U_M     nnnU R                  U5        [        S0 UD6$ [        U5      $ s  snnf )Nr   r   rG   )r   r<  r   rK   r  r   rr  r"   )r   r   kvro  s        rW   ru  SeriesParser._parsef  ss    499D4F4FG;;'!-1ZZ\:\TQs1vqy\G:!!'*$G$$$<	 ;s   Bc                >    U R                  SXR                  S9u  pU$ )Nr   r   )r  r   )r   rJ   r  s      rW   rw  SeriesParser._try_convert_typesp  s$    ''CUCU'V
rY   rG   N)r   r"   )rJ   r"   r   r"   	r   r   r   r   r   re  ru  rw  r   rG   rY   rW   r;  r;  b  s    O+K rY   r;  c                  0    \ rS rSrSrSrSS jrS	S jrSrg)
r9  iu  r`   )r`   rS   r   c                l   U R                   nU R                  nUS:X  a  [        XR                  S9R	                  5        VVs0 s H  u  p4[        U5      U_M     nnnU R                  U5        US    Vs/ s H%  n[        U[        5      (       a  [        U5      OUPM'     nn[        U[        US 5      5      US'   [        S	SS 0UD6$ US:X  a'  [        R                  " [        XR                  S9S SS9$ US:X  a  [        XR                  S9$ [        [        XR                  S9S S9$ s  snnf s  snf )
Nr   r  r`   r   rS   )r   rK   rc   )r   rG   )r<  rK   r   r   r  r   rr  rw   r1  tupler)   r+   r   	from_dictr/   )r   r<  rK   r  r  ro  r   
orig_namess           rW   ru  FrameParser._parsey  sN   yyW (<N<NOUUWWDA A	W   !!'* #9--C  *#t44s#=-   "-(T:"GI 343733w&&D0B0BC 
 w%d:L:LMM D0B0BC4 1
s   D+6,D1c                "   / nUR                  5        HP  u  p4U R                  UU[        U R                  U R                  US9S9u  pVUR                  UR                  5        MR     [        R                  " X!R                  UR                  SS9$ )N)r   r   r  F)verify_integrity)r  r  r  r   r   r   arrayr   _from_arraysr`   rS   )r   rJ   arrays	col_labelrC   r  r  s          rW   rw  FrameParser._try_convert_types  s    !$I..3&&'+'>'>! / IF MM&,,' "- %%KKU
 	
rY   rG   Nra  )rJ   r   r   r   r  rG   rY   rW   r9  r9  u  s    O.KB
rY   r9  c                   U SL a  g[        U [        5      (       d  U[        U 5      ;   a  gU(       d  g[        U[        5      (       d  gUR	                  5       nUR                  S5      (       d  US;   d  UR                  S5      (       a  gg)zD
Return bool whether a DataFrame column should be cast to datetime.
FT)_at_time>   datedatetimemodified	timestamp)rw   r   r   r   rg  endswith
startswith)r   r   r   	col_lowers       rW   r  r    s~     t,,M8J1JS!!		I+,,88,,rY   )............)rI   z0FilePath | WriteBuffer[str] | WriteBuffer[bytes]rJ   r@   rK   r   rL   r   rM   r   rN   r   rO   r   rP   r   rQ   r   rR   r6   rS   rY  rT   r   rU   r>   rV   Literal['a', 'w']r   r   )rI   r   rJ   r@   rK   r   rL   r   rM   r   rN   r   rO   r   rP   r   rQ   r   rR   r6   rS   rY  rT   r   rU   r>   rV   r  r   r   )Nre   
   Trh   NFr[   Nr   Nrb   )rI   z7FilePath | WriteBuffer[str] | WriteBuffer[bytes] | NonerJ   r@   rK   r   rL   r   rM   r   rN   r   rO   r   rP   r   rQ   r   rR   r6   rS   rY  rT   r   rU   r[  rV   r  r   r   )&rI   .FilePath | ReadBuffer[str] | ReadBuffer[bytes]rK   r   r   Literal['frame']r   r  r   rY  r   r  r   r   r   r   rO   r   r   r   r   r   rQ   r   r   r   rR   r6   r   rZ  rU   r>   r   r\  r   r;   r   r]  )&rI   r  rK   r   r   Literal['series']r   r  r   rY  r   r  r   r   r   r   rO   r   r   r   r   r   rQ   r   r   r   rR   r6   r   rZ  rU   r>   r   r\  r   r;   r   r^  )&rI   r  rK   r   r   r  r   r  r   rY  r   r  r   r   r   r   rO   r   r   r   r   r   rQ   r   r   r   rR   r6   r   rZ  rU   r>   r   r\  r   r;   r   r"   )&rI   r  rK   r   r   r  r   r  r   rY  r   r  r   r   r   r   rO   r   r   r   r   r   rQ   r   r   r   rR   r6   r   rZ  rU   r>   r   r\  r   r;   r   r   )&rI   r  rK   r   r   zLiteral['frame', 'series']r   r  r   rY  r   r  r   r   r   r   rO   r   r   r   r   r   rQ   r   r   rZ  rR   r6   r   rZ  rU   r[  r   r\  r   r;   r   zDataFrame | Series | JsonReader)r   r  r   r   r   r3   r   r   )h
__future__r   r   r   r   collections	itertoolsr   typingr   r	   r
   r   r   r   r   r   r  numpyry   pandas._configr   pandas._libsr   pandas._libs.jsonr   r   pandas._libs.tslibsr   pandas.compat._optionalr   pandas.errorsr   r   pandas.util._decoratorsr   pandas.util._validatorsr   pandas.core.dtypes.commonr   r   r   pandas.core.dtypes.dtypesr   r   r   r   r    r!   r"   r#   r$   r%   pandas.core.reshape.concatr&   pandas.io._utilr'   pandas.io.commonr(   r)   r*   r+   r,   pandas.io.json._normalizer-   pandas.io.json._table_schemar.   r/   r0   pandas.io.parsers.readersr1   collections.abcr2   r3   r4   typesr5   pandas._typingr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   pandas.core.genericr@   rA   rX   r   r   r   r   r   r3  Iteratorr   rd  r;  r9  r  rG   rY   rW   <module>r     s	   "  	 	 	   )  % > / 7 
 2	 	 	 . 1  ? 
 7 
 $   ,+7;L3MN 
 @C&)&)!A	  	
    >  $   $  
 
$ 
 @C&)&)!	  	
    >  $   $  	 
* @D&--1!sHs	s s 	s
 s s s >s s $s s s +s s sl1.S 1.hX6 X& <Q9k Q9h 
   #&)""%&)&)25''?' ' 
	'
 ' ' $' ' ' ' '  ' ' ' $'  !'" $#'$ 0%'& ''( ")' 
'. 
   #&)""%&)&)25'(?( ( 
	(
 ( ( $( ( ( ( (  ( ( ( $(  !(" $#($ 0%(& '(( #)( 
(. 
   #&)""%&)&)25'?  
	
   $         $  !" $#$ 0%& '( ) 
. 
   #&)""%&)&)25'?  
	
   $         $  !" $#$ 0%& '( ) 
. H &-! $&*# "* &--125.. '~"?~" ~" 
$	~"
 ~" ~" $~" ~" ~" ~" ~"  ~" ~" ~" $~"  !~"" +#~"$ 0%~"& '~"( %)~" ~"B
  Rw7 R !Rjq qh6 &4
& 4
n# 
 
	rY   