+
    nDj\                        ^ RI t ^ RIHt ^ RIHt ^ RIt^ RIHt ^ RIt^ RI	H
t
 ^ RIt^ RIt^ RIt^ RIt ^ RIt^ RIt^ RIHtHtHt / s/ s/ sR tR tR	 tR
 tR tR t R*R lt!R t"R t#R t$R t%R t&R t'R t(R t)R t*R t+R*R lt,R+R lt-R t.R,R lt/R t0R-R lt10 R.mt2R t3R t4R  t5R*R! lt6R*R" lt7R# t8R$ t9R% t:R& t;R' t<R( t=R) t>R#   ] d    Rt Li ; i)/    N)Sequence)futures)deepcopy)zip_longest)_pandas_api	frombytesis_threading_enabledc            	         \         '       Eg1   \         P                  / \        P                  P                  R b\        P                  P
                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  Rb\        P                  P                  R	b\        P                  P                  R
b\        P                  P                  Rb\        P                  P                   Rb\        P                  P"                  Rb\        P                  P$                  Rb\        P                  P&                  Rb\        P                  P(                  Rb\        P                  P*                  R\        P                  P,                  R\        P                  P.                  R/C4       \         # )emptyboolint8int16int32int64uint8uint16uint32uint64float16float32float64datetimebytesunicode)_logical_type_mapupdatepalibType_NA	Type_BOOL	Type_INT8
Type_INT16
Type_INT32
Type_INT64
Type_UINT8Type_UINT16Type_UINT32Type_UINT64Type_HALF_FLOAT
Type_FLOATType_DOUBLEType_DATE32Type_DATE64Type_TIME32Type_TIME64Type_BINARYType_FIXED_SIZE_BINARYType_STRING     O/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/pandas_compat.pyget_logical_type_mapr7   .   s       "
FFNNG"
FFf"
 FFf"
 FFw	"

 FFw"
 FFw"
 FFw"
 FF"
 FF"
 FF"
 FF""I"
 FFy"
 FF	"
 FF"
 FF"
  FF!"
" FF#"
$ FFFF))7FF	)"
 	, r5   c                    \        4       p WP                  ,          #   \         d    \        T \        P
                  P                  4      '       d    R # \        T \        P
                  P                  4      '       d   R\        T P                  4       R2u # \        T \        P
                  P                  4      '       d   T P                  e   Ru # Ru # \        P                  P                  T 4      '       d    R#  R# i ; i)categoricalzlist[]
datetimetzdatetimedecimalobject)r7   idKeyError
isinstancer   r   DictionaryTypeListTypeget_logical_type
value_typeTimestampTypetztypes
is_decimal)
arrow_typelogical_type_maps   & r6   rD   rD   K   s    +-.. 	j"&&"7"788 
BFFOO44+J,A,ABC1EE
BFF$8$899#-==#<<L*LXX  ,,	s(    5DAD:DD$DDc                     \         '       g   \         P                  \        P                  R \        P                  R\        P
                  R\        P                  R\        P                  R\        P                  R\        P                  R\        P                  R\        P                  R\        P                  R	\        P                  R
RR\        P                  R\        P                  R/4       \         # )r   r   r   r   r   r   r   r   r   r   r   datetime64[D]r   stringr   )_numpy_logical_type_mapr   npbool_r   r   r   r   r   r   r   r   r   r   str_bytes_r4   r5   r6   get_numpy_logical_type_maprT   \   s    ""&&HHfGGVHHgHHgHHgHHgIIxIIxIIxJJ	JJ	VGGXIIw(
 	  #"r5   c                 v   \        4       p WP                  P                  ,          #   \         d    \	        T P                  R 4      '       d    R# \        T P                  4      P                  R4      '       d   \        T P                  4      u # \        P                  ! T 4      pTR8X  d    R# Tu # i ; i)rG   r;   
datetime64rN   r   )	rT   dtypetyper@   hasattrstr
startswithr   infer_dtype)pandas_collectionnumpy_logical_type_mapresults   &  r6   get_logical_type_from_numpyr`   r   s    79%&=&=&B&BCC 
$**D11  &&'22<@@(..//(():;X
s!   ( 'B8?B8B83B87B8c                    V P                   p\        V4      R 8X  dY   \        V RV 4      pVf   Q hR\        VP                  4      RVP
                  /p\        VP                  P                   4      pWC3# \        VR4      '       d?   R\        P                  P                  VP                  4      /pRVP                   R2pWC3# Rp\        V4      pWC3# )	categorycatNnum_categoriesorderedrG   timezonezdatetime64[r:   )rW   rZ   getattrlen
categoriesre   codesrY   r   r   tzinfo_to_stringrG   unit)columnrW   catsmetadataphysical_dtypes   &    r6   get_extension_dtype_inforq      s    LLE
5zZvuf-c$//2t||
 TZZ--. ## 
		 7 7 AB&uzzl!4 ## U##r5   c           
        \        V4      p\        V 4      w  rVVR8X  d   RVP                  RVP                  /pRpVem   \	        V\
        4      '       d   \        P                  ! V4      '       g;   \	        V\        4      '       g%   \        RV R\        V4      P                   24      h\	        V\        4      '       g   Q \        \        V4      4      4       hRVRVR	VR
VRV/# )a  Construct the metadata for a given column

Parameters
----------
column : pandas.Series or pandas.Index
name : str
arrow_type : pyarrow.DataType
field_name : str
    Equivalent to `name` when `column` is a `Series`, otherwise if `column`
    is a pandas Index then `field_name` will not be the same as `name`.
    This is the name of the field in the arrow Table's schema.

Returns
-------
dict
r=   	precisionscaler>   z)Column name must be a string. Got column z	 of type name
field_namepandas_type
numpy_typero   )rD   rq   rs   rt   rA   floatrP   isnanrZ   	TypeErrorrX   __name__)rm   ru   rJ   rv   logical_typestring_dtypeextra_metadatas   &&&&   r6   get_column_metadatar      s    " $J/L#;F#C Ly --Z%%
   	D%((RXXd^^4%%7vYDz""#%
 	

 j#&&=D,<(==&j|lN r5   c                   Vf   V Uu. uF  p\        V4      NK  	  pp\        W44       U	U
u. uF   w  r\        V
\        4      '       d   K  W3NK"  	  pp	p
\	        V4      p\	        V4      pVRW,
           pWmV,
          R p. p\        WW~4       F(  w  pppp\        VVVVR7      pVP                  V4       K*  	  . pVRJEdI   . p\        W4       F  w  w  rpV	P                  e<   \        V	P                  \         4      '       g   VP                  V	P                  4       \        V	\        V	P                  4      VV
R7      pVP                  V4       K  	  \	        V4      ^ 8  d"   \        P                  ! RV R2\        ^R7       . p\        VP                  RVP                  .4      p\        VP                  RVP                  P                  .4      p\        VV4       F!  w  r\        W4      pVP                  V4       K#  	  M. ;p;pp\        VR	4      '       d   VP                   M/ p \"        P$                  ! V4       R\"        P$                  ! RVRVRVV,           RVRRRR\(        P*                  /R\,        P.                  /4      P1                  R4      /# u upi u up
p	i   \&         d.   p/ p\        P                  ! R
T R2\        ^R7        Rp?LRp?ii ; i)a  Returns a dictionary containing enough metadata to reconstruct a pandas
DataFrame as an Arrow Table, including index columns.

Parameters
----------
columns_to_convert : list[pd.Series]
df : pandas.DataFrame
column_names : list[str | None]
column_field_names: list[str]
index_levels : List[pd.Index]
index_descriptors : List[Dict]
preserve_index : bool
types : List[pyarrow.DataType]

Returns
-------
dict
N)ru   rJ   rv   Fz&The DataFrame has non-str index name `z@` which will be converted to string and not roundtrip correctly.
stacklevellevelsnamesattrsz(Could not serialize pd.DataFrame.attrs: z!, defaulting to empty attributes.s   pandasindex_columnscolumn_indexescolumns
attributescreatorlibrarypyarrowversionpandas_versionutf8)rZ   ziprA   dictrh   r   appendru   _column_name_to_stringswarningswarnUserWarningrg   r   _get_simple_index_descriptorrY   r   jsondumps	Exceptionr   __version__r   r   encode)columns_to_convertdfcolumn_namesindex_levelsindex_descriptorspreserve_indexrH   column_field_namesru   level
descriptorserialized_index_levelsnum_serialized_index_levelsntypesdf_typesindex_typescolumn_metadatacolrv   rJ   ro   index_column_metadatanon_str_index_namesr   r   r   r   es   &&&&&&&&                    r6   construct_metadatar      s   * ! 5AALDc$iLA "%\!E!EE*d+ 	!E   #&&="> ZF:f:;H!<<=>KO-01C1C.O)T:z&s2<2<> 	x(.O U" /2#0
+U zz%jS.I.I#**5::6*,UZZ8%%	H "((20
 "#a'MM89L8M N0 0 	+ X

|<

Gbjjoo->?vu-KE3E@H!!(+ . FHGG1N$R11rJ'

: 	4::.n)>>*92>> k11

 
 6&> K Bx  '
6qc :/ 0A	' 	''s(   J$J)J)4J/ /K':#K""K'c           
          \        V 4      w  r#\        V 4      pR V9   d   \        P                  ! R\        ^R7       VR8X  d   V'       d   Q hRR/pRVRVRVR	VR
V/# )mixedzlThe DataFrame has column names of mixed type. They will be converted to strings and not roundtrip correctly.r   r   encodingUTF-8ru   rv   rw   rx   ro   )rq   r`   r   r   r   )r   ru   r~   r   rw   s   &&   r6   r   r   2  sx    #;E#B L-e4K+@A	' i!!!$g.d{lN r5   c                   \        V \        4      '       d   V # \        V \        4      '       d   V P                  R4      # \        V \        4      '       d#   \        \	        \        \        V 4      4      4      # \        V \        4      '       d   \        R4      hV e3   \        V \        4      '       d   \        P                  ! V 4      '       d   V # \        V 4      # )a  Convert a column name (or level) to either a string or a recursive
collection of strings.

Parameters
----------
name : str or tuple

Returns
-------
value : str or tuple

Examples
--------
>>> name = 'foo'
>>> _column_name_to_strings(name)
'foo'
>>> name = ('foo', 'bar')
>>> _column_name_to_strings(name)
"('foo', 'bar')"
>>> import pandas as pd
>>> name = (1, pd.Timestamp('2017-02-01 00:00:00'))
>>> _column_name_to_strings(name)
"('1', '2017-02-01 00:00:00')"
r   z%Unsupported type for MultiIndex level)rA   rZ   r   decodetuplemapr   r   r{   ry   rP   rz   ru   s   &r6   r   r   F  s    2 $	D%	 	 {{6""	D%	 	 54d;<==	D(	#	#?@@	*T511bhhtnnt9r5   c                x    V P                   e'   V P                   V9  d   \        V P                   4      # RVR R2# )zReturn the name of an index level or a default name if `index.name` is
None or is already a column name.

Parameters
----------
index : pandas.Index
i : int

Returns
-------
name : str
__index_level_d__)ru   r   )indexir   s   &&&r6   _index_level_namer   m  s9     zz%**L"@&uzz22!uB''r5   c                    \        WV4      pV P                  P                  '       g"   \        R \	        V P                  4       24      hVe   \        WV4      # . p. pVRJd   \        V P                  4      M. p. p. pV F  p	W	,          p
\        V	4      p	\        P                  ! V
4      '       d   \        RV	 R24      hVP                  V
4       VP                  R4       VP                  V	4       VP                  \        V	4      4       K  	  . p. p\        V4       F  w  r\        WV4      p	\!        V\        P"                  P$                  4      '       d   Vf   \'        V4      pM5VP                  V4       VP                  R4       T	pVP                  V	4       VP                  V4       K  	  W\,           pVWEVWWx3# )zDuplicate column names found: NFSparse pandas data (column ) not supported.)_resolve_columns_of_interestr   	is_unique
ValueErrorlist$_get_columns_to_convert_given_schema_get_index_level_valuesr   r   r   	is_sparser{   r   rZ   	enumerater   rA   pd
RangeIndex_get_range_index_descriptor)r   schemar   r   r   r   r   r   convert_fieldsru   r   r   index_column_namesr   index_leveldescr	all_namess   &&&&             r6   _get_columns_to_convertr     s   *2w?G::,T"**-=,>?
 	
 3BOOL .<5-H) 
 Nh&t,  %%-dV3CDF F 	!!#&d#D!!!#d),  #L1 >{KNN$=$=>>&/<E%%k2!!$'E%%d+  ' 2 #7I |9K-?Q Qr5   c                   . p. p. p. p. p. pVP                    F  p	 W	,          p
Rp\        P                  ! T
4      '       d   \        RT	 R24      hTP                  T	4      pTP                  T
4       TP                  T4       TP                  T	4       T'       g   K  TP                  T	4       TP                  T	4       TP                  T
4       K  	  W7,           pWW7WhWE3#   \         d     \        Y	4      p
M$  \        \        3 d    \        RT	 R24      hi ; iTRJ d   \	        RT	 R24      hTf:   \        T
\        P                  P                  4      '       d   \	        RT	 R24      hRp ELQi ; i)	z
Specialized version of _get_columns_to_convert in case a Schema is
specified.
In that case, the Schema is used as the single point of truth for the
table structure (types, which columns are included, order of columns, ...).
Fzname 'zF' present in the specified schema is not found in the columns or indexzd' present in the specified schema corresponds to the index, but 'preserve_index=False' was specifiedz' is present in the schema, but it is a RangeIndex which will not be converted as a column in the Table, but saved as metadata-only not in columns. Specify 'preserve_index=True' to force it being added as a column, or remove it from the specified schemaTr   r   )r   r@   _get_index_level
IndexErrorr   rA   r   r   r   r   r{   fieldr   )r   r   r   r   r   r   r   r   r   ru   r   is_indexr   r   s   &&&           r6   r   r     s    LNL	(CH2   %%-dV3CDF F T"!!#&e$D!8%%d+$$T*$Q T 1I\-?Q QQ  	/&r0j) /TF #. ./ //
 & TF #   ! ! !(sKNN$=$=>> TF #' '( ( H-	s*   
C%%E91C=<E9=!DAE98E9c                    TpWP                   P                  9  d)   \        V4      '       d   \        V\	        R4      R 4      pV P                   P                  V4      # )zS
Get the index level of a DataFrame given 'name' (column name in an arrow
Schema).
r   )r   r   _is_generated_index_nameintrh   get_level_values)r   ru   keys   && r6   r   r      sP    
 C88>>!&>t&D&D $s+,R0188$$S))r5   c                 l     \         P                  ! V 4       V #   \         d    \        T 4      u # i ; iN)r   r   r{   rZ   r   s   &r6   _level_namer     s1    

4 4ys    33c                     R RR\        V P                  4      R\        P                  ! V R4      R\        P                  ! V R4      R\        P                  ! V R4      /# )kindrangeru   startstopstep)r   ru   r   get_rangeindex_attribute)r   s   &r6   r   r     sW     	EJJ'55eWE44UFC44UFC r5   c                     \        \        V R V .4      4      p\        V4       Uu. uF  q P                  V4      NK  	  up# u upi )r   )rh   rg   r   r   )r   nr   s   &  r6   r   r   !  s<    GE8eW-.A/4Qx8x!""1%x888s   Ac                     Ve   Ve   \        R4      hVe   VP                  pV# Ve&   V Uu. uF  q3V P                  9   g   K  VNK  	  ppV# V P                  pV# u upi )NzJSchema and columns arguments are mutually exclusive, pass only one of them)r   r   r   )r   r   r   cs   &&& r6   r   r   &  sw    g1 < = 	=		,, N 
	%9gbjj11g9 N **N	 :s   AAc                    \        V R W4      w  ppppppp	p. p
V	 EF@  pVP                  p\        P                  ! V4      '       d$   \        P
                  ! VRR7      P                  pM\        P                  ! V4      '       dh   \        V\        P                  P                  4      '       d   VP                  ^ 4      MVR,          p\        P
                  ! VRR7      P                  pM]\        WP                  R 4      w  r\        P                  P                  W4      pVf#   \        P
                  ! VRR7      P                  pV
P!                  V4       EKC  	  \#        WWHVWVR7      pW:V3# )NT)from_pandas:Nr   Nr   )r   valuesr   is_categoricalr   arrayrX   is_extension_array_dtyperA   r   Seriesheadget_datetimetz_typerW   r   _ndarray_to_arrow_typer   r   )r   r   r   r   r   r   _r   r   r   rH   r   r   type_r   ro   s   &&&             r6   dataframe_to_typesr   4  s8    ""dN
DYE%%f--HHQD166E11&99!+;>>(("* "*AFF1I/0u HHU5::E/FMFFF11&@E}5::U   "=N2DH
 X%%r5   c                   a \        WVV4      w  pppp	p
pppVfL   \        V 4      \        V P                  4      rW^d,          8  d   V^8  d   \        P                  ! 4       pM^p\        4       '       g   ^pV3R lpR pV^8X  d(   \        W4       UUu. uF  w  ppV! VV4      NK  	  pppM. p\        P                  ! V4      ;_uu_ 4       p\        W4       FZ  w  ppV! VP                  4      '       d   VP                  V! VV4      4       K8  VP                  VP                  VVV4      4       K\  	  R R R 4       \        V4       F;  w  pp\        V\        P                  4      '       g   K(  VP                  4       VV&   K=  	  V Uu. uF  pVP                   NK  	  ppVfU   . p\        VV4       F,  w  ppVP                  \        P"                  ! VV4      4       K.  	  \        P$                  ! V4      p\'        WW{V
VVVR7      pVP(                  '       d   \+        VP(                  4      M	\-        4       pVP/                  V4       VP1                  V4      pR p\        V4      ^ 8X  d_    V
^ ,          R,          p V R8X  dG   V
^ ,          R,          p!V
^ ,          R,          p"V
^ ,          R,          p#\        \3        V!V"V#4      4      pVVV3# u uppi   + '       g   i     EL; iu upi   \4         d     L1i ; i)	Nc                   < Vf   RpR pMVP                   pVP                  p \        P                  ! WRSR7      pT'       g.   TP                  ^ 8  d   \        RT RTP                   R24      hT#   \        P                  \        P
                  \        P                  3 d<   pT;P                  RT P                   RT P                   23,          un        ThR p?ii ; i)NT)rX   r   safezConversion failed for column z with type zField z( was non-nullable but pandas column had z null values)nullablerX   r   r   ArrowInvalidArrowNotImplementedErrorArrowTypeErrorargsru   rW   
null_countr   )r   r   field_nullabler   r_   r   r   s   &&    r6   convert_column+dataframe_to_arrays.<locals>.convert_columnp  s    =!NE"^^NJJE	XXc4dKF &"3"3a"7veW -$$*$5$5#6lD E E ++!!# 	 FF/zSYYKPS SFG	s   A4 44C#(6CC#c                     \        V \        P                  4      ;'       dM    V P                  P                  ;'       d/    \        V P                  P                  \        P                  4      # r   )	rA   rP   ndarrayflags
contiguous
issubclassrW   rX   integer)arrs   &r6   _can_definitely_zero_copy6dataframe_to_arrays.<locals>._can_definitely_zero_copy  sL    3

+ 7 7		$$7 7399>>2::6	8r5   r   r   r   r   r   r   )r   rh   r   r   	cpu_countr	   r   r   ThreadPoolExecutorr   r   submitr   rA   Futurer_   rX   r   r   r   ro   r   r   r   with_metadatar   r   )$r   r   r   nthreadsr   r   r   r   r   r   r   r   r   r   nrowsncolsr  r  r   farraysexecutorr   	maybe_futxrH   fieldsru   r   pandas_metadataro   n_rowsr   r   r   r   s$   &&&&&f                              r6   dataframe_to_arraysr#  W  s    /r>/68Y 2wBJJu3;519||~HH!!*8
 1}!"4EGEda !A&E 	 G ''11X.?1,QXX66MM.A"67MM(//.!Q"GH	 @ 2 &f-LAy)W^^44%,,.q	 . $$VQVVVE$~y%0KD%MM"((4/0 16"(=N2DO -3OOOx(HOOO$!!(+F F
6{a	$Q'/Dw)!,W5(+F3(+F3U5$56 66!![G 211 %6  		s,   KA*KK26AK7 K/	7LLc                 J   V P                   P                  \        P                  8w  d   W3# \        P
                  ! V4      '       d6   Vf2   VP                  pVP                  p\        P                  ! WC4      pW3# Vf!   \        P                  ! V P                   4      pW3# r   )rW   rX   rP   rV   r   is_datetimetzrG   rl   r   	timestampfrom_numpy_dtype)r   rW   r   rG   rl   s   &&&  r6   r   r     s    ||BMM)}  ''EMXXzzT&
 =	 
##FLL1=r5   c                .   ^ RI Hu Hp V P                  RR4      pV R,          pRV 9   d2   \        P
                  P                  WPR,          V R,          R7      pEMRV 9   d   \        P                  ! VP                  4      w  r\        WR,          4      p
\        P                  ! 4       '       d3   \        P                  P                  VP                  R4      V
R	R
7      pMTpV'       d!   VP                  WVVP                   V
R7      pV# MjRV 9   db   V R,          p\#        V4      ^8X  g   Q hW^ ,          ,          pW,,          p\%        VR4      '       g   \'        R4      hVP)                  V4      pMTpV'       d   VP                  WvR7      # Wv3# )a\  
Construct a pandas Block from the `item` dictionary coming from pyarrow's
serialization or returned by arrow::python::ConvertTableToPandas.

This function takes care of converting dictionary types to pandas
categorical, Timestamp-with-timezones to the proper pandas Block, and
conversion to pandas ExtensionBlock

Parameters
----------
item : dict
    For basic types, this is a dictionary in the form of
    {'block': np.ndarray of values, 'placement': pandas block placement}.
    Additional keys are present for other types (dictionary, timezone,
    object).
columns :
    Column names of the table being constructed, used for extension types
extension_columns : dict
    Dictionary of {column_name: pandas_dtype} that includes all columns
    and corresponding dtypes that will be converted to a pandas
    ExtensionBlock.

Returns
-------
pandas Block

Nblock	placement
dictionaryre   )ri   re   rf   r   F)rW   copy)r*  klassrW   py_array__from_arrow__zGThis column does not support to be converted to a pandas ExtensionArray)r*  )pandas.core.internalscore	internalsgetr   categorical_type
from_codesrP   datetime_datarW   make_datetimetz	is_ge_v21r   r   view
make_blockDatetimeTZBlockrh   rY   r   r/  )itemr   extension_columnsreturn_block_int	block_arrr*  r  rl   r   rW   r)  ru   pandas_dtypes   &&&&          r6   _reconstruct_blockrB    s   8 )($'I[!It**55|"4O 6 % 
t	""9??3:&67  ""..&&w'u5 ' C C	.2.B.B.3 ( 5 	 
 
t	:9~"""|$(.|%566 : ; ;))#.s88~r5   c                     \         P                  ! 4       '       d   R p \        P                  P	                  V4      p\         P
                  ! WR7      # )nsrG   )r   is_v1r   r   string_to_tzinfodatetimetz_type)rl   rG   s   &&r6   r7  r7    s;    		 	 	$B&&t33r5   c           
         . p. p/ pVP                   P                  pV'       gb   Ve^   VR,          pVP                  R. 4      pVP                  R/ 4      pVR,          p	\        W4      p\	        WWT4      w  r\        WW@V4      pM7\        P                  P                  VP                  4      p
\        V. W@V4      p\        V4       \        WV4      pVP                  p\        P                  P                  WV\!        VP#                  4       4      4      p\        P$                  ! 4       '       d7   ^ RIHp V Uu. uF  p\+        VWRR7      NK  	  ppV! VWR7      pVVn        V# ^ R	IHp ^ R
IHp V Uu. uF  p\+        VW4      NK  	  ppW.pV! VV4      p\        P6                  ! 4       '       d   VP9                  VVP:                  4      pMV! V4      pVVn        V# u upi u upi )Nr   r   r   r   )create_dataframe_from_blocksF)r>  )r   r   )BlockManager)	DataFrame)r   r!  r3  _add_any_metadata_reconstruct_index_get_extension_dtypesr   r   r   num_rows'_check_data_column_metadata_consistency_deserialize_column_indexr   r   r   table_to_blocksr   keysis_ge_v3pandas.api.internalsrJ  rB  r   r0  rK  pandasrL  r8  	_from_mgraxes)optionstableri   ignore_metadatatypes_mapperall_columnsr   r   r!  r   r   ext_columns_dtypesr   r   r_   rJ  r<  blocksr   rK  rL  rY  mgrs   &&&&&                  r6   table_to_dataframerb    s    KNJll22O:%i0(,,-=rB$((r:
+O<!%9)%*5E2zC ))%..922|j
 ,K8'NKG%%LVV##GJ$();)@)@)B$CEFE
 
  lUL 	 

 *&O	6$ 
 t\F 	 
 64(  ""$$S#((3B3B	5

s   =G%9G*c                   VR,          pT;'       g    . p/ p\         P                  f   V# V'       d<   V P                   F+  pVP                  pV! V4      p	V	f   K  WVP                  &   K-  	  V P                   Fc  pVP                  pVP                  V9  g   K"  \        V\        P                  4      '       g   KD   VP                  4       p	WVP                  &   Ke  	  V EF  p
 V
R,          pV
R,          pW9  g   K  V\        9  g   K,  \         P                  ! V4      p	\        V	\         P                  4      '       g   Kd  \        V	\         P                  P                  4      '       d]   V'       g   W9   d   K   \        P                  P!                  V P                  P#                  V4      P                  4      '       d   K   \%        V	R4      '       g   K  WV&   EK  	  \         P&                  ! 4       '       Ed   V'       Eg   V P                   F  pVP                  V9  g   K  \        P                  P)                  VP                  4      '       ga   \        P                  P+                  VP                  4      '       g2   \        P                  P-                  VP                  4      '       g   K  VP                  V9  g   K  \         P                  P                  \.        P0                  R7      WgP                  &   K  	  V#   \         d     EK  i ; i  \         d    T
R,          p ELLi ; i  \         d     ELi ; i)a  
Based on the stored column pandas metadata and the extension types
in the arrow schema, infer which columns should be converted to a
pandas extension dtype.

The 'numpy_type' field in the column metadata stores the string
representation of the original pandas dtype (and, despite its name,
not the 'pandas_type' field).
Based on this string representation, a pandas/numpy dtype is constructed
and then we can check if this dtype supports conversion from arrow.

strings_to_categoricalrv   ru   rx   r/  )na_value)r   extension_dtyper   rX   ru   rA   r   BaseExtensionTypeto_pandas_dtypeNotImplementedErrorr@   _pandas_supported_numpy_typesrA  r   StringDtyperH   is_dictionaryr   rY   uses_string_dtype	is_stringis_large_stringis_string_viewrP   nan)r[  columns_metadatar]  rZ  ri   rd  ext_columnsr   typrA  col_metaru   rW   s   &&&&&        r6   rO  rO  b  s    %%=>!!rJK ""* \\E**C',L'*6EJJ'	 " jj::[(ZR=Q=Q-R-R7"224 +7EJJ'  %	$L)D &"u4Q'Q '33E:L,(C(CDDlKNN,F,FGG .1C 8811%,,2D2DT2J2O2OPP$ Q <)9::(4%5 %: $$&&/E/E\\Ezz,""5::..88++EJJ7788**5::66**J.*5..*D*Dbff*D*UJJ' " Y '   	$F#D	$( $ s7    L)	L'AML$#L$'L?>L?MMc                 ~    \         ;QJ d    R  V  4       F  '       d   K   RM	  RM! R  V  4       4      '       g   Q hR# )c              3   x   "   T F0  pVR ,          RJ ;'       d    RV9   ;'       g    VR ,          RJx  K2  	  R# 5i)ru   Nrv   r4   ).0r   s   & r6   	<genexpr>:_check_data_column_metadata_consistency.<locals>.<genexpr>  sA      A 
6d		0	0|q0JJQvYd5JJs   :::FTN)all)r^  s   &r6   rQ  rQ    s=    
 3 333     r5   c           
         V'       dd   V Uu/ uF-  pVP                  R \        VR,          4      4      VR,          bK/  	  ppV P                   Uu. uF  qTP                  WU4      NK  	  ppMV P                  p\        V4      ^8  dd   \        P
                  P                  P                  \        \        \        P                  V4      4      V Uu. uF  qwR,          NK  	  upR7      pM8\        P
                  P                  Yb'       d   V^ ,          R,          MRR7      p\        V4      ^ 8  d   \        W4      pV# u upi u upi u upi )rv   ru   r   Nr   )r3  r   r   rh   r   r   
MultiIndexfrom_tuplesr   r   astliteral_evalIndex"_reconstruct_columns_from_metadata)	block_tabler^  r   r   columns_name_dictru   columns_values	col_indexr   s	   &&&      r6   rR  rR    s=    !
  EE, 7&	 BCQvYN  	 

 ;F:R:R
:R$!!$-:R 	 
 %11 >Q ..++77S%%~676DEnV$$nE 8 

 ..&&n!26!:RV ' 

 >Q4WMN9

 Fs   3E EE

c                 t   V Uu/ uF  pVP                  R VR,          4      VbK  	  pp. p. pT pV F  p	\        V	\        4      '       d   \        WWV4      w  rpV
f   K/  MV	R,          R8X  d^   V	R,          p\        P
                  P                  V	R,          V	R,          V	R,          VR7      p
\        V
4      \        V 4      8w  d   K  M\        RV	R,           24      hVP                  V
4       VP                  V4       K  	  \        P
                  p\        V4      ^8  d    VP                  P                  WgR	7      pW3# \        V4      ^8X  dA   V^ ,          p\        WP                  4      '       g   VP                  W^ ,          R
7      pW3# VP                  V P                  4      pW3# u upi )rv   ru   r   r   r   r   r   )r   ru   zUnrecognized index kind: r}  r   )r3  rA   rZ   _extract_index_levelr   r   r   rh   r   r   r~  from_arraysr  rP  )r[  r   r^  r]  r   field_name_to_metadataindex_arraysindex_namesresult_tabler   r   
index_namer   r   s   &&&&          r6   rN  rN    s    A 	
lAfI&)   LKL"eS!!4HUL5R1Lz" # 6]g%vJ%..33E'N49&M9>v9C 4 EK ;3u:- . 8vHIIK(:&' #* 
B <1)),)J  
\	a	Q%**HHUQH8E  enn-Ys   #F5c                 4   W2,          R ,          p\        W%4      pV P                  P                  V4      pVR8X  d   VRR3# V P                  V4      pVP	                  VR7      p	RV	n        VP                  VP                  P                  V4      4      pWV3# )ru   N)r]  ) _backwards_compatible_index_namer   get_field_indexrm   	to_pandasru   remove_column)
r[  r  rv   r  r]  logical_namer  r   r   r   s
   &&&&&     r6   r  r    s    )5f=L1*KJ$$Z0ABwT4''
,,q/C--\-:KK--++J7L j00r5   c                8    W8X  d   \        V 4      '       d   R# V# )a  Compute the name of an index column that is compatible with older
versions of :mod:`pyarrow`.

Parameters
----------
raw_name : str
logical_name : str

Returns
-------
result : str

Notes
-----
* Part of :func:`~pyarrow.pandas_compat.table_to_blockmanager`
N)r   )raw_namer  s   &&r6   r  r  )  s    $ $<X$F$Fr5   c                 6    R p\         P                  ! W4      RJ# )z^__index_level_\d+__$N)rematch)ru   patterns   & r6   r   r   A  s    &G88G"$..r5   c                     \         '       gp   \         P                  R RRRRRRRR\        P                  RRR	\        P                  R
\        P
                  R\        P                  R\        P                  /
4       \         # )r   rM   r<   zdatetime64[ns]r;   r   rZ   r   rN   r  floatingr=   r   )_pandas_logical_type_mapr   rP   rS   r   r   object_r4   r5   r6   get_pandas_logical_type_mapr  F  sm     $# ''O(*uRYYerxx

rzzRZZ)
 	 $#r5   c                    \        4       p W,          #   \         d3    RT 9   d   \        P                  u # \        P                  ! T 4      u # i ; i)zGet the numpy dtype that corresponds to a pandas type.

Parameters
----------
pandas_type : str
    The result of a call to pandas.lib.infer_dtype.

Returns
-------
dtype : np.dtype
    The dtype that corresponds to `pandas_type`.
r   )r  r@   rP   r  rW   )rw   pandas_logical_type_maps   & r6   _pandas_type_to_numpy_typer  Y  sK     :;%&33 %k!::xx$$	%s    "AAAc                   \         P                  p\        V RR4      ;'       g    V .p\        V RR4      ;'       g    R.p\        W1/ R7       UUu. uF<  w  rVWVP	                  R\        VP                  4      4      VP	                  RR4      3NK>  	  ppp. p\        P                  ! RR4      p	V EF  w  rZp\        V
4      pV\        P                  8X  d   VP                  V	4      pEMLV
R	8X  d   \        P                  P                  V^ ,          R
,          R,          4      pVP!                  VRR7      P#                  V4      p\         P$                  ! 4       '       d-   VP'                  \        P(                  ! V4      ^ ,          4      pMV
R8X  dE   \         P                  P+                  V Uu. uF  p\,        P.                  ! V4      NK  	  up4      pM\VP                  R8X  d*   VR8X  d#   RV
9   g   V
R9   d   VP1                  V4       EKd  VP                  V8w  d   VP3                  V4      pVP                  V8w  d   V
R	8w  d   VP3                  V4      pVP1                  V4       EK  	  \5        V4      ^8  d   VP7                  WV P8                  R7      # VP+                  V^ ,          V^ ,          P                  V P:                  R7      # u uppi u upi )a  Construct a pandas MultiIndex from `columns` and column index metadata
in `column_indexes`.

Parameters
----------
columns : List[pd.Index]
    The columns coming from a pyarrow.Table
column_indexes : List[Dict[str, str]]
    The column index metadata deserialized from the JSON schema metadata
    in a :class:`~pyarrow.Table`.

Returns
-------
result : MultiIndex
    The index reconstructed using `column_indexes` metadata with levels of
    the correct type.

Notes
-----
* Part of :func:`~pyarrow.pandas_compat.table_to_blockmanager`
r   Nrj   )	fillvaluerw   rx   r   r   r;   ro   rf   T)utcr=   rZ   r>   r   r}  )rW   ru   )r   rN   )r   r   rg   r   r3  rZ   rW   operatormethodcallerr  rP   rS   r   r   r   rG  to_datetime
tz_convertrU  as_unitr6  r  r=   Decimalr   astyperh   r~  r   ru   )r   r   r   r   labelsr   r  levels_dtypes
new_levelsencoderrA  numpy_dtyperW   rG   r   s   &&             r6   r  r  p  so   , 
B Wh-::'FWgt,66F !,b!
!
E 
mS-=>	|T	*	,!
   J##Hg6G,9([*<8 BIIIIg&E\)((q!*-j9;BNN5dN3>>rBE##%% b&6&6{&CA&FGY&NN((e)Le'//!*<e)LMEKK5 [H%<L(L<Q,Q e$[[E!LL'E;;+%,,*FLL-E% O -:R :}}Zw}}}EExx
1Z]-@-@w||xTTo: *Ms   AK4K
c                    / p/ pV P                   pVR ,          pV Uu. uF  p\        V\        4      '       g   K  VNK  	  pp\        V4      p\        VR,          4      V,
          p\	        VR,          4       EFk  w  rV
P                  R4      pV'       g%   V
R,          pW8  d   WYV,
          ,          pVf   RpVP                  V4      pVR8w  g   K]  V
R,          R8X  g   Km  W,          p\        VP                  \        P                  P                  4      '       g   K  V
R,          pV'       g   K  VP                  R4      pV'       g   K  WP                  P                  8w  g   K  VP                  4       p\        P                  ! R	VR
7      p\        P                  P                  VVR7      p\        P                   ! WL,          P"                  V4      W<&   VW,&   EKn  	  \        V4      ^ 8  d   . p. p\%        \        V P                   4      4       Fr  p	W9   d1   VP'                  W),          4       VP'                  W9,          4       K9  VP'                  W	,          4       VP'                  V P                   V	,          4       Kt  	  \        P(                  P+                  V\        P                   ! V4      R7      # V # u upi )r   r   rv   ru   Nonerw   r;   ro   rf   rD  rE  )rX   )r   r  )r   rA   rZ   rh   r   r3  r  rX   r   r   rF   rG   r  r&  Arrayr   r   ru   r   r   Tabler  )r[  r!  modified_columnsmodified_fieldsr   r   idx_coln_index_levels	n_columnsr   ru  r  idxr   ro   metadata_tz	convertedtz_aware_typer  r   r   s   &&                   r6   rM  rM    s;   O\\F#O4M,9 2M"7C0 WMM 2'NOI./.@I !!;<<<-'H~(Y7!$$X."9&,6j!#((BFF,@,@AA#J/&ll:6;;((++#= #I$&LL+$FM$&HH$8$8>K %9 %MM ,.88FK4D4D4A,CO(,9$)= =@ q s5<<()A$/23o01ux(ell1o. * xx##GBIIf4E#FFe2s
   KKc                    \         P                  P                  V4      pV P                  P	                  R4      P                  P                  V4      p V # )z:
Make a datetime64 Series timezone-aware for the given tz
r  )r   r   rG  dttz_localizer  )seriesrG   s   &&r6   make_tz_awarer    sA     
	 	 	$Bii##E*R

2 Mr5   r   )   NT)NNT)NFN>   r   r   r   r   r   r   r>   r   r   r   r   r   r   )?r  collections.abcr   
concurrentr   concurrent.futures.threadr,  r   r=   	itertoolsr   r   r  r  r   numpyrP   ImportErrorr   r   pyarrow.libr   r   r	   r   rO   r  r7   rD   rT   r`   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r#  r   rB  r7  rb  rj  rO  rQ  rR  rN  r  r  r   r  r  r  rM  r  r4   r5   r6   <module>r     s5  &  $  !   !   	   D D    :"#,"$&,^jZ($N(&?QD;Q|
*9
 &Fa"H&BJ4;@! PfB2j1&0/
$&%.TUn:BK'  	Bs   C 	CC