
    bi                       d Z ddlmZ ddlZddlmZ ddlmZ  ed      Z	 ed      Z
 ed      Z ed	      Z ed
      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z	 	 	 	 	 ddZd ZddZd Zd dZd!dZ y)"z4
Dispatch in dask.dataframe.

Also see extension.py
    )annotationsN)is_dask_collection)Dispatchmake_meta_dispatchmake_meta_objmeta_nonemptymeta_lib_from_arrayhash_object_dispatchgroup_split_dispatchget_parallel_typeCategoricalDtypeconcattolistis_categorical_dtypeunion_categoricalsgrouperpartd_encode_dispatchpyarrow_schema_dispatchfrom_pyarrow_table_dispatchto_pyarrow_table_dispatchto_pandas_dispatchc           	         t        |       dk(  r| d   S t        j                  t        | d               } || f|||||d|S )a  Concatenate, handling some edge cases:

    - Unions categoricals between partitions
    - Ignores empty partitions

    Parameters
    ----------
    dfs : list of DataFrame, Series, or Index
    axis : int or str, optional
    join : str, optional
    uniform : bool, optional
        Whether to treat ``dfs[0]`` as representative of ``dfs[1:]``. Set to
        True if all arguments have the same columns and dtypes (but not
        necessarily categories). Default is False.
    ignore_index : bool, optional
        Whether to allow index values to be ignored/dropped during
        concatenation. Default is False.
    ignore_order : bool, optional
        Whether to ignore the order when doing the union of categoricals.
        Default is False.
       r   )axisjoinuniformfilter_warningignore_index)lenconcat_dispatchdispatchtype)dfsr   r   r   r   r   kwargsfuncs           R/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/dask/dataframe/dispatch.pyr   r   "   s^    < 3x1}1v''SV5
)%
 
 	
    c                h    t        | d|       } t        j                  t        |             } ||       S )Ndtype)getattris_categorical_dtype_dispatchr!   r"   objr%   s     r&   r   r   O   s.    
#w
$C(11$s)<D9r'   c                R    t         j                  t        |             } |||      S )N)
categoriesordered)categorical_dtype_dispatchr!   r"   )metar/   r0   r%   s       r&   categorical_dtyper3   U   s#    %..tDz:D:w77r'   c                N    t         j                  t        |             } ||       S )N)tolist_dispatchr!   r"   r,   s     r&   r   r   Z   s     ##DI.D9r'   c                   t        | t        j                  t        j                  t        j                  f      s#t        | d      rt        |       r| j                  S 	 t        | |      S # t        $ r\ |*t        j                  t        |            } || |      cY S t        j                  t        j                        } || |      cY S w xY w)a  
    This method creates meta-data based on the type of ``x``,
    and ``parent_meta`` if supplied.

    Parameters
    ----------
    x : Object of any type.
        Object to construct meta-data from.
    index :  Index, optional
        Any index to use in the metadata. This is a pass-through
        parameter to dispatches registered.
    parent_meta : Object, default None
        If ``x`` is of arbitrary types and thus Dask cannot determine
        which back-end to be used to generate the meta-data for this
        object type, in which case ``parent_meta`` will be used to
        determine which back-end to select and dispatch to. To use
        utilize this parameter ``make_meta_obj`` has be dispatched.
        If ``parent_meta`` is ``None``, a pandas DataFrame is used for
        ``parent_meta`` that chooses pandas as the backend.

    Returns
    -------
    A valid meta-data
    _meta)index)
isinstancepdSeries	DataFrameIndexhasattrr   r7   r   	TypeErrorr   r!   r"   )xr8   parent_metar%   s       r&   	make_metarB   _   s    4 a"))R\\288<='!WBUa 77N
(!!511 (" ))${*;<D'' !))",,7D''(s   A+ +3C -CCc                Z    t         j                  t        | d               } || ||      S )Nr   )sort_categoriesignore_order)union_categoricals_dispatchr!   r"   )to_unionrD   rE   r%   s       r&   r   r      s*    &//Xa[0ABD/UUr'   )r   outerFTF)NF)NN)FF)!__doc__
__future__r   pandasr:   daskr   
dask.utilsr   r   r   r   r	   r
   r   r   r1   r    r5   r+   rF   grouper_dispatchr   r   r   r   r   r   r   r3   r   rB   r    r'   r&   <module>rP      s   #  # 23 ))45  67  67 01 %&89 8$8$ ()? @ &';< I&  !89 "#<= &'DE $%@A 23 
 
	*
Z8

((VVr'   