o
    $if,                     @   s(  d dl Z d dlmZ d dlmZ d dlZd dlmZ d dlm	Z	 d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlmZmZ i add Zd	d
 Zejdejdejdejdejdejdejdejdej dej!dej"dddej#dej$diZ%dd Z&dd Z'dd Z(d d! Z)d"d# Z*d$d% Z+d&d' Z,d(d) Z-d*d+ Z.d,d- Z/d.d/ Z0d0d1 Z1d2d3 Z2d4d5 Z3d^d6d7Z4		9d_d:d;Z5d<d= Z6d`d>d?Z7d@dA Z8	dadCdDZ9h dEZ:d^dFdGZ;dHdI Z<dJdK Z=d^dLdMZ>	d^dNdOZ?dPdQ Z@dRdS ZAddTdTej#ej$ej#ejej"ejBdU	ZCdVdW ZDdXdY ZEdZd[ ZFd\d] ZGdS )b    N)Sequence)futures)deepcopy)zip_longest)_pandas_api	frombytesc                	   C   s   t sjt i tjjdtjjdtjjdtjjdtjjdtjj	dtjj
dtjjdtjjd	tjjd
tjjdtjjdtjjdtjjdtjjdtjjdtjjdtjjdtjjdtjjdi t S )N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 r1   r1   N/var/www/html/corbot_env/lib/python3.10/site-packages/pyarrow/pandas_compat.pyget_logical_type_map)   sR   	
r3   c                 C   s   t  }z|| j W S  tyL   t| tjjrY dS t| tjjr+dt	| j
 Y S t| tjjr?| jd ur;d Y S d Y S t| tjjrIY dS Y dS w )Ncategoricalzlist[{}]
datetimetzdatetimedecimalobject)r3   idKeyError
isinstancer   r   DictionaryTypeListTypeformatget_logical_type
value_typeTimestampTypetzDecimal128Type)
arrow_typelogical_type_mapr1   r1   r2   r?   F   s   r?   r	   r
   r   r   r   r   r   r   r   r   r   zdatetime64[D]r   stringr   c                 C   sd   zt | jj W S  ty1   t| jdrY dS t| jdkr!Y dS t| }|dkr-Y dS | Y S w )NrB   r5   datetime64[ns]rF   r   )_numpy_logical_type_mapdtypetyper:   hasattrstrr   infer_dtype)pandas_collectionresultr1   r1   r2   get_logical_type_from_numpyi   s   
rP   c                 C   s   | j }t|dkr(t| d| }|d usJ t|j|jd}t|jj }||fS t|dr<dtj	
|ji}d}||fS d }t|}||fS )Ncategorycat)num_categoriesorderedrB   timezonerG   )rI   rL   getattrlen
categoriesrT   codesrK   r   r   tzinfo_to_stringrB   )columnrI   catsmetadataphysical_dtyper1   r1   r2   get_extension_dtype_infox   s    
r_   c                 C   s   t |}t| \}}|dkr|j|jd}d}|dur+t|ts+td|t|j	|du s<t|ts<J tt|||du rCdn||||dS )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
    r7   )	precisionscaler8   Nz6Column name must be a string. Got column {} of type {}Nonename
field_namepandas_type
numpy_typer]   )
r?   r_   r`   ra   r;   rL   	TypeErrorr>   rJ   __name__)r[   rd   rD   re   logical_typestring_dtypeextra_metadatar1   r1   r2   get_column_metadata   s,   

rm   c              	   C   s  t dd |D }t |}|d||  }	||| d }
g }t| ||	D ]\}}}t||||d}|| q%g }|durg }t||
|D ],\}}}t|trQqF|jdurbt|jtsb||j t|t|j||d}|| qFt |dkrt	j
d| dtd	d
 g }t|jd|jg}t|jd|jjg}t||D ]\}}t||}|| qng  } }}dt|||| dtjdtjddiS )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
    index_levels : List[pd.Index]
    index_descriptors : List[Dict]
    preserve_index : bool
    types : List[pyarrow.DataType]

    Returns
    -------
    dict
    c                 S   s   g | ]	}t |ts|qS r1   )r;   dict).0descrr1   r1   r2   
<listcomp>       
z&construct_metadata.<locals>.<listcomp>N)rd   rD   re   Fr   z&The DataFrame has non-str index name `z@` which will be converted to string and not roundtrip correctly.   
stacklevellevelsnamess   pandaspyarrow)libraryversion)index_columnscolumn_indexescolumnscreatorpandas_versionutf8)rW   ziprm   appendr;   rn   rd   rL   _column_name_to_stringswarningswarnUserWarningrV   r}   _get_simple_index_descriptorjsondumpsr   __version__r   rz   encode)columns_to_convertdfcolumn_namesindex_levelsindex_descriptorspreserve_indextypesnum_serialized_index_levelsntypesdf_typesindex_typescolumn_metadatacolsanitized_namerD   r]   index_column_metadatanon_str_index_nameslevel
descriptorr|   rv   rw   rd   r1   r1   r2   construct_metadata   sl   


	r   c                 C   sT   t | \}}t| }d|v rtjdtdd |dkr"|rJ ddi}|||||dS )	NmixedzlThe DataFrame has column names of mixed type. They will be converted to strings and not roundtrip correctly.rs   rt   r   encodingUTF-8rc   )r_   rP   r   r   r   )r   rd   rk   rl   rf   r1   r1   r2   r     s    r   c                 C   sd   t | tr| S t | tr| dS t | trtttt| S t | tr(td| du r.dS t| S )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 levelN)	r;   rL   r   decodetuplemapr   r   rh   rd   r1   r1   r2   r   "  s   




r   c                 C   s(   | j dur| j |vrt| j S d|S )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
    Nz__index_level_{:d}__)rd   r   r>   )indexir   r1   r1   r2   _index_level_nameI  s   

r   c                 C   s:  t | ||}| jjstdt| j|d urt| ||S g }|dur)t| jng }g }g }|D ]%}| | }	t	|}t
|	rGtd|||	 |d  || q1g }
g }t|D ]0\}}t|||}t|t
jjry|d u ryt|}n|| |d  |}|| |
| q_|| }||||
|||fS )Nz Duplicate column names found: {}F-Sparse pandas data (column {}) not supported.)_resolve_columns_of_interestr}   	is_unique
ValueErrorr>   list$_get_columns_to_convert_given_schema_get_index_level_valuesr   r   r   	is_sparserh   r   	enumerater   r;   pd
RangeIndex_get_range_index_descriptor)r   schemar   r}   r   r   r   convert_fieldsrd   r   r   index_column_namesr   index_levelrp   	all_namesr1   r1   r2   _get_columns_to_convert\  sN   






r   c                 C   s:  g }g }g }g }g }g }|j D ]}	z| |	 }
d}W n@ tyY   zt| |	}
W n ttfy7   td|	w |du rCtd|	|du rUt|
tjj	rUtd|	d}Y nw t
|	}	t|
rjtd|	||	}||
 || ||	 |r||	 ||	 ||
 q|| }|||||||fS )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, ...).
    FzNname '{}' present in the specified schema is not found in the columns or indexzlname '{}' present in the specified schema corresponds to the index, but 'preserve_index=False' was specifiedNa  name '{}' 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   )rw   r:   _get_index_level
IndexErrorr>   r   r;   r   r   r   r   r   rh   fieldr   )r   r   r   r   r   r   r   r   r   rd   r   is_indexr   r   r1   r1   r2   r     sf   








r   c                 C   s8   |}|| j jvrt|rt|tdd }| j |S )z_
    Get the index level of a DataFrame given 'name' (column name in an arrow
    Schema).
    __index_level_)r   rw   _is_generated_index_nameintrW   get_level_values)r   rd   keyr1   r1   r2   r     s   r   c                 C   s,   zt |  | W S  ty   t|  Y S w N)r   r   rh   rL   r   r1   r1   r2   _level_name  s   
r   c                 C   s.   dt | jt| dt| dt| ddS )Nrangestartstopstep)kindrd   r   r   r   )r   rd   r   get_rangeindex_attribute)r   r1   r1   r2   r     s   


r   c                    s(   t t d g} fddt|D S )Nrv   c                    s   g | ]}  |qS r1   )r   )ro   r   r   r1   r2   rq     s    z+_get_index_level_values.<locals>.<listcomp>)rW   rV   r   )r   nr1   r   r2   r     s   r   c                    sR   |d ur|d urt d|d ur|j}|S |d ur$ fdd|D }|S  j}|S )NzJSchema and columns arguments are mutually exclusive, pass only one of themc                    s   g | ]	}| j v r|qS r1   )r}   ro   cr   r1   r2   rq   	  s    z0_resolve_columns_of_interest.<locals>.<listcomp>)r   rw   r}   )r   r   r}   r1   r   r2   r     s   r   c                 C   s   t | d ||\}}}}}}}g }	|D ]T}
|
j}t|r%tj|
ddj}n<t|rEt|
tj	j
r6|
dn|
d d }tj|ddj}nt||
jd \}}tj||}|d u ratj|
ddj}|	| qt|| |||||	}||	|fS )NT)from_pandasr   )r   valuesr   is_categoricalr   arrayrJ   is_extension_array_dtyper;   r   Seriesheadget_datetimetz_typerI   r   _ndarray_to_arrow_typer   r   )r   r   r}   r   r   _r   r{   r   r   r   r   type_r   r]   r1   r1   r2   dataframe_to_types  s<   



r      Tc           !   	      sD  t | |||\}}}}	}
}}|d u r-t| t| j}}||d kr+|dkr+t }nd}fdd dd }|dkrH fddt||D }nNg }t|*}t||D ]\}}||jrg|	 || qU|	|
 || qUW d    n1 s|w   Y  t|D ]\}}t|tjr| ||< qd	d |D }|d u rg }t||D ]\}}|d ur|nd
}|	t|| qt|}t|| ||
|	||}|jrt|jnt }|| ||}d }t|dkrz'|	d d }|dkr|	d d }|	d d }|	d d } tt||| }W n
 ty   Y nw |||fS )Nd   r   c              
      s   |d u r	d}d }n|j }|j}ztj| |d d}W n" tjtjtjfy< } z| jd| j	| j
f7  _|d }~ww |sO|jdkrOtdt||j|S )NT)rJ   r   safez0Conversion failed for column {!s} with type {!s}r   z>Field {} was non-nullable but pandas column had {} null values)nullablerJ   r   r   ArrowInvalidArrowNotImplementedErrorArrowTypeErrorargsr>   rd   rI   
null_countr   rL   )r   r   field_nullabler   rO   e)r   r1   r2   convert_columnG  s0   z+dataframe_to_arrays.<locals>.convert_columnc                 S   s$   t | tjo| jjot| jjtjS r   )	r;   npndarrayflags
contiguous
issubclassrI   rJ   integer)arrr1   r1   r2   _can_definitely_zero_copy]  s
   z6dataframe_to_arrays.<locals>._can_definitely_zero_copyc                    s   g | ]	\}} ||qS r1   r1   )ro   r   f)r   r1   r2   rq   c  s    z'dataframe_to_arrays.<locals>.<listcomp>c                 S   s   g | ]}|j qS r1   rJ   )ro   xr1   r1   r2   rq   r  s    rb   r   r   r   r   r   r   )r   rW   r}   r   	cpu_countr   r   ThreadPoolExecutorr   r   submitr   r;   FuturerO   r   r   r   r]   r   rn   r   with_metadatar   r   )!r   r   r   nthreadsr}   r   r   r   r   r   r{   r   r   nrowsncolsr   arraysexecutorr   r   r   	maybe_futr   fieldsrd   r   pandas_metadatar]   n_rowsr   r   r   r   r1   )r   r   r2   dataframe_to_arrays2  sz   







r  c                 C   sd   | j jtjkr| |fS t|r$|d u r$|j}|j}t	||}| |fS |d u r.t
| j }| |fS r   )rI   rJ   r   
datetime64r   is_datetimetzrB   unitr   	timestampfrom_numpy_dtype)r   rI   r   rB   r  r1   r1   r2   r     s   r   c                 C   s$  ddl m  m} | dd}| d }d| v r%tjj|| d | d d}n`d| v rZt|j	\}}	t
|| d }
t rItjj|d	|
d
d}n<|}|rY|j|||j|
d}|S n+d| v r| d }t|dksjJ ||d  }|| }t|ds}td||}n|}|r|j||dS ||fS )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

    r   Nblock	placement
dictionaryrT   )rX   rT   rU   r   F)rI   copy)r
  klassrI   py_arrayr   __from_arrow__zGThis column does not support to be converted to a pandas ExtensionArray)r
  )pandas.core.internalscore	internalsgetr   categorical_type
from_codesr   datetime_datarI   make_datetimetz	is_ge_v21r   r   view
make_blockDatetimeTZBlockrW   rK   r   r  )itemr}   extension_columnsreturn_block_int	block_arrr
  r   r  r   rI   r	  rd   pandas_dtyper1   r1   r2   _reconstruct_block  sF   
r"  c                 C   s&   t  rd} tj|}t j| |dS )NnsrB   )r   is_v1r   r   string_to_tzinfodatetimetz_type)r  rB   r1   r1   r2   r    s   r  Fc                    sN  g }g }|j j}|s1|d ur1|d }|dg }|d }t||}t||||\}}	t|||ntj|j	}	t|g |t
| t|||}
|j tj| ||t }t ruddlm}  fdd|D }|||	|
d}|S dd	lm} dd
lm}  fdd|D }|
|	g}|||}t r|||j}|S ||}|S )Nr}   r|   r{   r   )create_dataframe_from_blocksc                    s   g | ]
}t | d dqS )F)r  r"  ro   r  r   ext_columns_dtypesr1   r2   rq     s    z&table_to_dataframe.<locals>.<listcomp>)r   r}   )BlockManager)	DataFramec                    s   g | ]}t | qS r1   r)  r*  r+  r1   r2   rq     s    
)r   r  r  _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.internalsr(  r  r-  pandasr.  r  	_from_mgraxes)optionstablerX   ignore_metadatatypes_mapperall_columnsr|   r  r   r   r}   rO   r(  blocksr   r-  r.  r;  mgrr1   r+  r2   table_to_dataframe  sR   


rC  >   r	   r
   r   r   r   r   r8   r   r   r   r   r   r   c           
   	   C   s   i }t jdu r	|S |D ]2}z|d }W n ty    |d }Y nw |d }|tvr=t |}t|t jr=t|dr=|||< q| jD ] }|j}	t|	t	j
raz|	 }W n	 ty[   Y qAw |||j< qA|rz| jD ]}|j}	||	}|dury|||j< qg|S )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.

    Nre   rd   rg   r  )r   extension_dtyper:   _pandas_supported_numpy_typesr!  r;   rK   r   rJ   r   BaseExtensionTypeto_pandas_dtypeNotImplementedErrorrd   )
r=  columns_metadatar?  ext_columnscol_metard   rI   r!  r   typr1   r1   r2   r1  2  sD   






r1  c                 C   s   t dd | D sJ d S )Nc                 s   s0    | ]}|d  du rd|v p|d  duV  qdS )rd   Nre   r1   r   r1   r1   r2   	<genexpr>p  s
    
z:_check_data_column_metadata_consistency.<locals>.<genexpr>)all)r@  r1   r1   r2   r3  k  s   r3  c                    s   |rdd |D   fdd| j D }n| j }t|dkr2tjjjtttj	|dd |D d}ntjj
||r>|d d	 nd d
}t|dkrMt||}|S )Nc                 S   s&   i | ]}| d t|d |d qS re   rd   )r  r   r   r1   r1   r2   
<dictcomp>x  s    z-_deserialize_column_index.<locals>.<dictcomp>c                    s   g | ]}  ||qS r1   r  )ro   rd   columns_name_dictr1   r2   rq   |  s    z-_deserialize_column_index.<locals>.<listcomp>r   c                 S   s   g | ]}|d  qS r   r1   )ro   	col_indexr1   r1   r2   rq     s    rw   r   rd   r   )r   rW   r   r   
MultiIndexfrom_tuplesr   r   astliteral_evalIndex"_reconstruct_columns_from_metadata)block_tabler@  r|   columns_valuesr}   r1   rR  r2   r4  v  s&   

r4  c                 C   s6  dd |D }g }g }| }|D ]O}t |tr't| ||||\}}	}
|	d u r&qn-|d dkrK|d }
tjj|d |d |d |
d	}	t|	t| krJqn	td
|d |	|	 |	|
 qtj}t|dkrt|j
j||d}||fS t|dkr|d }t ||js|j||d d}||fS || j}||fS )Nc                 S   s   i | ]}| d |d |qS rO  rQ  r   r1   r1   r2   rP    s    z&_reconstruct_index.<locals>.<dictcomp>r   r   rd   r   r   r   )r   rd   zUnrecognized index kind: {}r   rU  r   r   )r;   rL   _extract_index_levelr   r   r   rW   r   r>   r   rV  from_arraysrZ  r2  )r=  r   r@  r?  field_name_to_metadataindex_arraysindex_namesresult_tablerp   r   
index_namer   r   r1   r1   r2   r0    sP   




	r0  c           
      C   sl   || d }t ||}| j|}|dkr|d d fS | |}|j|d}	d |	_||j|}||	|fS )Nrd   )r?  ) _backwards_compatible_index_namer   get_field_indexr[   	to_pandasrd   remove_column)
r=  rc  re   r`  r?  logical_namerd  r   r   r   r1   r1   r2   r^    s   




r^  c                 C   s   | |kr
t | r
dS |S )a1  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_namerj  r1   r1   r2   rf    s   rf  c                 C   s   d}t || d uS )Nz^__index_level_\d+__$)rematch)rd   patternr1   r1   r2   r     s   r   rG   )	r   r6   r5   r   r   rF   r   floatingr   c                 C   s:   zt |  W S  ty   d| v rtj Y S t|  Y S w )a  Get 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   )_pandas_logical_type_mapr:   r   object_rI   )rf   r1   r1   r2   _pandas_type_to_numpy_type
  s   

rr  c                 C   s(  t j}t| ddp| g}t| ddpdg}dd t||i dD }g }tdd}|D ]K\}}	}
t|	}|tjkr>|	|}|	d	krYt
j|d
 d d }|j|dd|}n
|j|krc||}|j|
krq|	d	krq||
}|| q+t|dkr|j||| jdS |j|d
 |d
 j| jdS )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`
    rv   NrY   c                 S   s0   g | ]\}}|| d t|j| ddfqS )rf   rg   N)r  rL   rI   )ro   r   rT  r1   r1   r2   rq   =  s    
z6_reconstruct_columns_from_metadata.<locals>.<listcomp>)	fillvaluer   r   r5   r   r]   rU   T)utcr   rU  )rI   rd   )r   r   rV   r   operatormethodcallerrr  r   bytes_r   r   r   r&  to_datetime
tz_convertrI   astyper   rW   rV  rw   rZ  rd   )r}   r|   r   rv   labelslevels_dtypes
new_levelsencoderr   r!  numpy_dtyperI   rB   r1   r1   r2   r[     s6   




r[  c                 C   s  i }i }| j }|d }dd |D }t|}t|d | }t|d D ]q\}}	|	d}
|
sC|	d }
||kr=|||  }
|
d u rCd}
||
}|dkr|	d	 d
kr| | }t|jtjj	s_q$|	d }|sfq$|d}|r||jj
kr| }tjd|d}tjj||d}t|| j|||< |||< q$t|dkrg }g }tt| j D ]$}||v r|||  |||  q|| |  || j |  qtjj|t |dS | S )Nr{   c                 S   s   g | ]	}t |tr|qS r1   )r;   rL   )ro   idx_colr1   r1   r2   rq   j  rr   z%_add_any_metadata.<locals>.<listcomp>r}   re   rd   rb   re  rf   r5   r]   rU   r#  r$  r   r   )r   )r   rW   r   r  rg  r;   rJ   r   r   rA   rB   rh  r  Arrayr   r   rd   r   r   Tabler_  )r=  r  modified_columnsmodified_fieldsr   r{   n_index_levels	n_columnsr   rK  rk  idxr   r]   metadata_tz	convertedtz_aware_typer   r}   r   r1   r1   r2   r/  b  s^   


r/  c                 C   s$   t j|}| jdj|} | S )zB
    Make a datetime64 Series timezone-aware for the given tz
    rt  )r   r   r&  dttz_localizery  )seriesrB   r1   r1   r2   make_tz_aware  s
   
r  r   )r   NT)NNT)NFN)HrX  collections.abcr   
concurrentr   concurrent.futures.threadr  r   	itertoolsr   r   ru  rl  r   numpyr   rx   r   pyarrow.libr   r   r   r3   r?   bool_r
   r   r   r   r   r   r   r   r   r   str_rw  rH   rP   r_   rm   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r"  r  rC  rE  r1  r3  r4  r0  r^  rf  r   rq  rp  rr  r[  r/  r  r1   r1   r1   r2   <module>   s   -V'@@	
"
b
E
7
9
!7
BA