o
    iP                     @  s   d Z ddlmZ ddlmZmZmZ ddlZddl	m
Z
mZmZ ddlmZ ddlmZmZ ddlmZ dd	lmZmZ ed
ddZG dd deZG dd deZdddZdS )zc
Base class for the internal managers. Both BlockManager and ArrayManager
inherit from this class.
    )annotations)LiteralTypeVarfinalN)	ArrayLikeDtypeObjShapeAbstractMethodError)find_common_typenp_can_hold_element)PandasObject)Indexdefault_indexTDataManager)boundc                   @  s   e Zd ZU ded< ed5ddZed6dd	Zed6d
dZed7ddZ	ed8ddZ
				d9d:ddZe		d;d<d d!Zd=d#d$Zed>d&d'Z		d;d?d+d,Zed@d-d.ZdAd/d0Zd@d1d2ZdBd3d4ZdS )Cr   zlist[Index]axesreturnr   c                 C     t | Nr	   self r   U/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pandas/core/internals/base.pyitems*      zDataManager.itemsintc                 C  
   t | jS r   )lenr   r   r   r   r   __len__.      
zDataManager.__len__c                 C  r   r   )r   r   r   r   r   r   ndim2   r!   zDataManager.ndimr   c                 C  s   t dd | jD S )Nc                 s  s    | ]}t |V  qd S r   )r   ).0axr   r   r   	<genexpr>8   s    z$DataManager.shape.<locals>.<genexpr>)tupler   r   r   r   r   shape6   s   zDataManager.shapeaxis
new_labelsNonec                 C  sR   t | j| }t |}|dkrt | jdkrd S ||kr'td| d| dd S )N   r   z#Length mismatch: Expected axis has z elements, new values have z	 elements)r   r   r   
ValueError)r   r(   r)   old_lennew_lenr   r   r   _validate_set_axis:   s   zDataManager._validate_set_axisNFTr   r   
allow_dupsboolcopy
only_slicec                 C  r   r   r	   )r   new_axisindexerr(   
fill_valuer0   r2   r3   r   r   r   reindex_indexerK   s   
zDataManager.reindex_indexer	new_indexc                 C  s*   | j | |\}}| j||||d|dS )z4
        Conform data manager to new index.
        F)r(   r6   r2   r3   )r   reindexr7   )r   r8   r(   r6   r3   r5   r   r   r   reindex_axisW   s   zDataManager.reindex_axisotherc                 C  r   )z
        To be implemented by the subclasses. Only check the column values
        assuming shape and indexes have already been checked.
        r	   )r   r;   r   r   r   _equal_valuesm   s   zDataManager._equal_valuesobjectc                 C  sV   t |tsdS | j|j}}t|t|krdS tdd t||D s&dS | |S )z5
        Implementation for DataFrame.equals
        Fc                 s  s    | ]
\}}| |V  qd S r   )equals)r#   ax1ax2r   r   r   r%      s    z%DataManager.equals.<locals>.<genexpr>)
isinstancer   r   r   allzipr<   )r   r;   	self_axes
other_axesr   r   r   r>   t   s   

zDataManager.equals
align_keyslist[str] | Noneignore_failuresc                 K  r   r   r	   )r   frF   rH   kwargsr   r   r   apply   s   zDataManager.applyc                 C  s   | j d|dS )NrK   )func)rK   )r   rL   r   r   r   isna   s   zDataManager.isnac                 C     dS )NTr   r   r   r   r   is_consolidated      zDataManager.is_consolidatedc                 C  s   | S r   r   r   r   r   r   consolidate   rP   zDataManager.consolidatec                 C  s   d S r   r   r   r   r   r   _consolidate_inplace   rP   z DataManager._consolidate_inplace)r   r   )r   r   )r   r   )r(   r   r)   r   r   r*   )NFTF)r   r   r(   r   r0   r1   r2   r1   r3   r1   r   r   )NF)
r   r   r8   r   r(   r   r3   r1   r   r   )r   r   r;   r   r   r1   )r;   r=   r   r1   )r   r   rF   rG   rH   r1   r   r   )r   r   r   r   )r   r1   r   r*   )__name__
__module____qualname____annotations__propertyr   r   r    r"   r'   r/   r7   r:   r<   r>   rK   rM   rO   rQ   rR   r   r   r   r   r   $   s@   
 
	

c                   @  sP   e Zd ZedddZeedddZdd	d
ZddddZe	dddZ
dS )SingleDataManagerr   
Literal[1]c                 C  rN   )Nr+   r   r   r   r   r   r"      s   zSingleDataManager.ndimr   c                 C  s
   | j d S )zW
        Quick access to the backing array of the Block or SingleArrayManager.
        r   )arraysr   r   r   r   array   s   
zSingleDataManager.arrayr*   c                 C  s*   | j }t|tjrt|j|}|||< dS )a'  
        Set values with indexer.

        For Single[Block/Array]Manager, this backs s[indexer] = value

        This is an inplace version of `setitem()`, mutating the manager/values
        in place, not returning a new Manager (and Block), and thus never changing
        the dtype.
        N)r\   rA   npndarrayr   dtype)r   r5   valuearrr   r   r   setitem_inplace   s   
z!SingleDataManager.setitem_inplaceFrH   r1   c                 C  s.   | j }||}tt|}t| ||}|S )z
        ignore_failures : bool, default False
            Not used; for compatibility with ArrayManager/BlockManager.
        )r\   r   r   type
from_array)r   rL   rH   ra   resindexmgrr   r   r   grouped_reduce   s
   z SingleDataManager.grouped_reducera   rf   r   c                 C  r   r   r	   )clsra   rf   r   r   r   rd      r   zSingleDataManager.from_arrayN)r   rZ   )r   r   rS   )F)rH   r1   )ra   r   rf   r   )rT   rU   rV   rX   r"   r   r\   rb   rh   classmethodrd   r   r   r   r   rY      s    
rY   dtypeslist[DtypeObj]r   DtypeObj | Nonec                 C  s   t | sdS t| S )z
    Find the common dtype for `blocks`.

    Parameters
    ----------
    blocks : List[DtypeObj]

    Returns
    -------
    dtype : np.dtype, ExtensionDtype, or None
        None is returned when `blocks` is empty.
    N)r   r   )rk   r   r   r   interleaved_dtype   s   rn   )rk   rl   r   rm   )__doc__
__future__r   typingr   r   r   numpyr]   pandas._typingr   r   r   pandas.errorsr
   pandas.core.dtypes.castr   r   pandas.core.baser   pandas.core.indexes.apir   r   r   r   rY   rn   r   r   r   r   <module>   s    z4