
    Mh                    @   S r SSKJr  SSKrSSKrSSKJr  SSKJ	r	J
r
Jr  SSKr\R                  (       a  SSKJr  0 SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S%_S&S'_S(S)S*S+S,S-S.S/S0S1S2S3S4S5.Er " S6 S75      r " S8 S95      rS<S: jrS=S; jrg)>zE
Utility functions and objects for implementing the interchange API.
    )annotationsN)lib)
ArrowDtypeCategoricalDtypeDatetimeTZDtype)DtypeObjnullnboolbuint8Cuint16Suint32Iuint64Lint8cint16int32iint64l	halffloatefloatfdoublegstringularge_stringUbinaryzz	time32[s]ttsttmttuttntdDtdmztss:ztsm:ztsu:ztsn:tDstDmtDutDn)z
time32[ms]z
time64[us]z
time64[ns]zdate32[day]z
date64[ms]ztimestamp[s]ztimestamp[ms]ztimestamp[us]ztimestamp[ns]zduration[s]zduration[ms]zduration[us]zduration[ns]c                  d    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSrSrSrg)ArrowCTypes=   z
Enum for Apache Arrow C type format strings.

The Arrow C data interface:
https://arrow.apache.org/docs/format/CDataInterface.html#data-type-description-format-strings
r
   r   r   r   sr   r   r   r   r   r   r   r!   r#   r%   r,   r-   zts{resolution}:{tz}ztt{resolution} N)__name__
__module____qualname____firstlineno____doc__NULLBOOLINT8UINT8INT16UINT16INT32UINT32INT64UINT64FLOAT16FLOAT32FLOAT64STRINGLARGE_STRINGDATE32DATE64	TIMESTAMPTIME__static_attributes__r6       O/var/www/html/env/lib/python3.13/site-packages/pandas/core/interchange/utils.pyr3   r3   =   sj     DDDEEFEFEFGGGFLFF &IDrP   r3   c                  (    \ rS rSrSrSrSrSrSrSr	g)	
Endianness_   z.Enum indicating the byte-order of a data-type.<>=|r6   N)
r7   r8   r9   r:   r;   LITTLEBIGNATIVENArO   r6   rP   rQ   rS   rS   _   s    8F
CF	BrP   rS   c                Z   [        U [        5      (       a  [        R                  $ U [        R
                  " S5      :X  a  [        R                  $ [        U [        5      (       a  SSKnU R                  nUR                  R                  U5      (       a  SUR                   SUR                   3$ UR                  R                  U5      (       a,  UR                  b  SUR                   S    SUR                   3$ ["        R%                  ['        U5      S5      nUb  U$ [)        [        U R*                  R-                  5       S5      nUb  U$ [.        R0                  " U S5      (       a:  [        R2                  " U 5      S   S   n[        R4                  R7                  US	S
9$ [        U [8        5      (       a5  [        R4                  R7                  U R                   S   U R                  S
9$ [        U [:        R<                  5      (       a  [        R>                  $ [A        SU  S35      e)z
Represent pandas `dtype` as a format string in Apache Arrow C notation.

Parameters
----------
dtype : np.dtype
    Datatype of pandas DataFrame to represent.

Returns
-------
str
    Format string in Apache Arrow C notation of the given `dtype`.
Or   Nzd:,ts:M )
resolutiontzzConversion of z- to Arrow C format string is not implemented.)!
isinstancer   r3   rD   npdtyperI   r   pyarrowpyarrow_dtypetypes
is_decimal	precisionscaleis_timestampre   unitPYARROW_CTYPESgetstrgetattrnameupperr   is_np_dtypedatetime_datarM   formatr   pdBooleanDtyper=   NotImplementedError)rh   papa_type
format_strrd   s        rQ   dtype_to_arrow_c_fmtr   h   s    %)**   	"((3-	!!!	E:	&	&%%88w''))*!GMM?;;XX""7++

0FQ('**66#''Gd;
!ejj&6&6&8$?J
uc"" %%e,Q/2
$$++zb+II	E?	+	+$$++uzz!}+RR	E2??	+	+

LM rP   c               b   [        U R                  [        R                  5      (       d  gU R                  R
                  n[        UR                  5      S:X  a  gU(       d  [        S5      eUR                  5       n[        R                  " X0R                  U R                  U R                  S9$ )a  
Rechunk a multi-chunk pyarrow array into a single-chunk array, if necessary.

- Returns `None` if the input series is not backed by a multi-chunk pyarrow array
  (and so doesn't need rechunking)
- Returns a single-chunk-backed-Series if the input is backed by a multi-chunk
  pyarrow array and `allow_copy` is `True`.
- Raises a `RuntimeError` if `allow_copy` is `False` and input is a
  based by a multi-chunk pyarrow array.
N   zFound multi-chunk pyarrow array, but `allow_copy` is False. Please rechunk the array before calling this function, or set `allow_copy=True`.)rh   ru   index)rf   rh   rz   r   array	_pa_arraylenchunksRuntimeErrorcombine_chunksSeriesru   r   )series
allow_copychunked_arrayarrs       rQ   maybe_rechunkr      s     fllBMM22LL**M
= A%!
 	

 
&
&
(C99S6;;fllSSrP   )rh   r   returnrs   )r   z	pd.Seriesr   r   r   zpd.Series | None)r;   
__future__r   typingnumpyrg   pandas._libsr   pandas.core.dtypes.dtypesr   r   r   pandasrz   TYPE_CHECKINGpandas._typingr   rq   r3   rS   r   r   r6   rP   rQ   <module>r      sR   #     	'

C
C S c	
 c c C S S S  S c c C  c!" #$ =D D 0fTrP   