
    `Vg*2                       d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
mZmZ ddlZddlZddlmZ ddlmZmZmZ ddlmZ dd	lmZ dd
lmZmZmZmZmZm Z  ddl!Z"ddl#m$Z$ ddl%m&Z& erddl!m'Z'm(Z( 	 	 	 	 	 	 	 	 	 	 	 	 ddZ) G d de      Z* G d de*      Z+ G d de*      Z,ddZ-ddZ.	 	 	 	 	 	 ddZ/	 	 	 	 	 	 ddZ0d dZ1	 	 	 	 	 	 d!dZ2	 	 	 	 d"dZ3y)#z
Module responsible for execution of NDFrame.describe() method.

Method NDFrame.describe() delegates actual execution to function describe_ndframe().
    )annotations)ABCabstractmethod)TYPE_CHECKINGAnyCallableHashableSequencecastN)	Timestamp)DtypeObjNDFrameTnpt)find_stack_level)validate_percentile)is_bool_dtypeis_complex_dtypeis_datetime64_any_dtypeis_extension_array_dtypeis_numeric_dtypeis_timedelta64_dtype)concat)format_percentiles)	DataFrameSeriesc                    t        |      }| j                  dk(  rt        t        d|       |      }nt	        t        d|       |||      }|j                  |      }t        t        |      S )a  Describe series or dataframe.

    Called from pandas.core.generic.NDFrame.describe()

    Parameters
    ----------
    obj: DataFrame or Series
        Either dataframe or series to be described.
    include : 'all', list-like of dtypes or None (default), optional
        A white list of data types to include in the result. Ignored for ``Series``.
    exclude : list-like of dtypes or None (default), optional,
        A black list of data types to omit from the result. Ignored for ``Series``.
    datetime_is_numeric : bool, default False
        Whether to treat datetime dtypes as numeric.
    percentiles : list-like of numbers, optional
        The percentiles to include in the output. All should fall between 0 and 1.
        The default is ``[.25, .5, .75]``, which returns the 25th, 50th, and
        75th percentiles.

    Returns
    -------
    Dataframe or series description.
       r   objdatetime_is_numericr   )r   includeexcluder    )percentiles)refine_percentilesndimSeriesDescriberr   DataFrameDescriberdescriber   )r   r!   r"   r    r#   	describerresults          U/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/core/describe.pydescribe_ndframer,   6   ss    > %[1K xx1}#Xs# 3
	
 '[#& 3	
	 K8F&!!    c                  *    e Zd ZdZddZedd       Zy)NDFrameDescriberAbstractzAbstract class for describing dataframe or series.

    Parameters
    ----------
    obj : Series or DataFrame
        Object to be described.
    datetime_is_numeric : bool
        Whether to treat datetime dtypes as numeric.
    c                     || _         || _        y Nr   )selfr   r    s      r+   __init__z!NDFrameDescriberAbstract.__init__t   s    #6 r-   c                     y)zDo describe either series or dataframe.

        Parameters
        ----------
        percentiles : list-like of numbers
            The percentiles to include in the output.
        N )r2   r#   s     r+   r(   z!NDFrameDescriberAbstract.describex   s    r-   N)r   DataFrame | Seriesr    boolreturnNone)r#   Sequence[float] | np.ndarrayr8   r6   )__name__
__module____qualname____doc__r3   r   r(   r5   r-   r+   r/   r/   i   s     7  r-   r/   c                  $    e Zd ZU dZded<   ddZy)r&   z2Class responsible for creating series description.r   r   c                h    t        | j                  | j                        } || j                  |      S r1   )select_describe_funcr   r    )r2   r#   describe_funcs      r+   r(   zSeriesDescriber.describe   s/    ,HH$$
 TXX{33r-   N)r#   r:   r8   r   )r;   r<   r=   r>   __annotations__r(   r5   r-   r+   r&   r&      s    <	K4r-   r&   c                  F     e Zd ZdZ	 	 	 	 	 	 	 	 	 	 d fdZddZd Z xZS )r'   a  Class responsible for creating dataobj description.

    Parameters
    ----------
    obj : DataFrame
        DataFrame to be described.
    include : 'all', list-like of dtypes or None
        A white list of data types to include in the result.
    exclude : list-like of dtypes or None
        A black list of data types to omit from the result.
    datetime_is_numeric : bool
        Whether to treat datetime dtypes as numeric.
    c                   || _         || _        |j                  dk(  r$|j                  j                  dk(  rt        d      t        |   ||       y )N   r   z+Cannot describe a DataFrame without columns)r    )r!   r"   r%   columnssize
ValueErrorsuperr3   )r2   r   r!   r"   r    	__class__s        r+   r3   zDataFrameDescriber.__init__   sN     88q=S[[--2JKK2EFr-   c           	     n   | j                         }g }|j                         D ]3  \  }}t        || j                        }|j	                   |||             5 t        |      }t        |D cg c]  }|j                  |d       c}dd      }	|j                  j                         |	_        |	S c c}w )NF)copyr   )axissort)
_select_dataitemsrA   r    appendreorder_columnsr   reindexrG   rM   )
r2   r#   dataldesc_seriesrB   	col_namesxds
             r+   r(   zDataFrameDescriber.describe   s      "  	=IAv09Q9QRMLLv{;<	= $E*	7<=!QYYyuY-=

 LL%%'	 >s   -B2c                   | j                   || j                  pt        j                  g}| j                  r|j                  d       | j                  j                  |      }t        |j                        dk(  r| j                  }|S | j                   dk(  r'| j                  d}t        |      | j                  }|S | j                  j                  | j                   | j                        }|S )zSelect columns to be described.datetime)r!   r   allz*exclude must be None when include is 'all')r!   r"   )r!   r"   npnumberr    rR   r   select_dtypeslenrG   rI   )r2   default_includerU   msgs       r+   rP   zDataFrameDescriber._select_data   s    LL t||';46II;O''&&z288))/)BD4<< A%xx  \\U"||'B o%88D 	 88)) * D r-   )
r   r   r!   str | Sequence[str] | Noner"   re   r    r7   r8   r9   )r#   r:   r8   r   )r;   r<   r=   r>   r3   r(   rP   __classcell__)rK   s   @r+   r'   r'      sM    GG ,	G
 ,G "G 
G "r-   r'   c                    g }t        d | D        t              }|D ]  }|D ]  }||vs|j                  |        ! |S )z,Set a convenient order for rows for display.c              3  4   K   | ]  }|j                     y wr1   )index).0rZ   s     r+   	<genexpr>z"reorder_columns.<locals>.<genexpr>   s     3AGG3s   )key)sortedrb   rR   )rV   namesldesc_indexesidxnamesnames        r+   rS   rS      sR    E3U3=M! # 	#D5 T"	## Lr-   c                   ddl m} t        |      }g d|z   dgz   }| j                         | j	                         | j                         | j                         g| j                  |      j                         z   | j                         gz   }t        |       rt        j                         }n.t        |       r!t        |       st        j                   d      }nd} |||| j"                  |      S )zDescribe series containing numerical data.

    Parameters
    ----------
    series : Series
        Series to be described.
    percentiles : list-like of numbers
        The percentiles to include in the output.
    r   r   )countmeanstdminmaxfloatNri   rq   dtype)pandasr   r   rt   ru   rv   rw   quantiletolistrx   r   pdFloat64Dtyper   r   r_   r{   rq   )rX   r#   r   formatted_percentiles
stat_indexr[   r{   s          r+   describe_numeric_1dr      s     .{;03HHE7RJ	

fjjlC
//+
&
-
-
/	0::<.	   '!	&	!*:6*B!!:FKKuEEr-   c                <   g d}| j                         }t        ||dk7           }|dkD  r!|j                  d   |j                  d   }}d}n"t        j
                  t        j
                  }}d}| j                         |||g}ddlm}	  |	||| j                  |      S )zDescribe series containing categorical data.

    Parameters
    ----------
    data : Series
        Series to be described.
    percentiles_ignored : list-like of numbers
        Ignored, but in place to unify interface.
    )rt   uniquetopfreqr   Nobjectrs   rz   )
value_countsrb   ri   ilocr_   nanrt   r|   r   rq   )
rU   percentiles_ignoredrn   	objcountscount_uniquer   r   r{   r*   r   s
             r+   describe_categorical_1dr     s     /E!!#Iya01LaOOA&	q(9T FFBFFTjjlL#t4F&DIIUCCr-   c                   ddg}| j                         }t        ||dk7           }| j                         |g}d}|dkD  r|j                  d   |j                  d   }}| j
                  j                  }	| j                         j                  j                  d      }
t        |      }|j                  |	|j                  |	      }n|j                  |	      }|g dz  }|||t        |
j                         |	      t        |
j                         |	      gz  }n,|dd	gz  }|t         j"                  t         j"                  gz  }d
}ddlm}  |||| j(                  |      S )zDescribe series containing timestamp data treated as categorical.

    Parameters
    ----------
    data : Series
        Series to be described.
    percentiles_ignored : list-like of numbers
        Ignored, but in place to unify interface.
    rt   r   r   Ni8)r   r   firstlast)tzr   r   r   rs   rz   )r   rb   rt   ri   r   dtr   dropnavaluesviewr   tzinfo
tz_converttz_localizerw   rx   r_   r   r|   r   rq   )rU   r   rn   r   r   r*   r{   r   r   r   asintr   s               r+   $describe_timestamp_as_categorical_1dr   !  sG    hE!!#Iya01LjjlL)FEaOOA&	q(9TWWZZ$$))$/n::!bn..$C//"%C11eiikb)eiikb)	
 	
 	% 266266""&DIIUCCr-   c                &   ddl m} t        |      }g d|z   dgz   }| j                         | j	                         | j                         g| j                  |      j                         z   | j                         gz   } |||| j                        S )zDescribe series containing datetime64 dtype.

    Parameters
    ----------
    data : Series
        Series to be described.
    percentiles : list-like of numbers
        The percentiles to include in the output.
    r   rs   )rt   ru   rw   rx   )ri   rq   )
r|   r   r   rt   ru   rw   r}   r~   rx   rq   )rU   r#   r   r   r   r[   s         r+   describe_timestamp_1dr   Q  s     .{;),AAUGKJ	tyy{DHHJ/
--
$
+
+
-	.88:,	 
 !:DII66r-   c                *   t        | j                        rt        S t        |       rt        S t        | j                        r2|rt        S t        j                  dt        t                      t        S t        | j                        rt        S t        S )zSelect proper function for describing series based on data type.

    Parameters
    ----------
    data : Series
        Series to be described.
    datetime_is_numeric : bool
        Whether to treat datetime dtypes as numeric.
    zTreating datetime data as categorical rather than numeric in `.describe` is deprecated and will be removed in a future version of pandas. Specify `datetime_is_numeric=True` to silence this warning and adopt the future behavior now.)
stacklevel)r   r{   r   r   r   r   r   warningswarnFutureWarningr   r   r   )rU   r    s     r+   rA   rA   i  sv     TZZ &&	$	""	 	,((MMJ +- 87	djj	)""&&r-   c                .   | t        j                  g d      S t        |       } t        |        d| vr| j	                  d       t        j
                  |       } t        j                  |       }| J t        |      t        |       k  rt        d      |S )z
    Ensure that percentiles are unique and sorted.

    Parameters
    ----------
    percentiles : list-like of numbers, optional
        The percentiles to include in the output.
    )g      ?      ?g      ?r   z%percentiles cannot contain duplicates)	r_   arraylistr   rR   asarrayr   rb   rI   )r#   unique_pctss     r+   r$   r$     s     xx)** {#K $ +3**[)K ))K(K"""
;#k**@AAr-   )r   r   r!   re   r"   re   r    r7   r#   #Sequence[float] | np.ndarray | Noner8   r   )rV   zSequence[Series]r8   zlist[Hashable])rX   r   r#   Sequence[float]r8   r   )rU   r   r   r   r8   r   )rU   r   r#   r   r8   r   )rU   r   r    r7   r8   r   )r#   r   r8   z%np.ndarray[Any, np.dtype[np.float64]])4r>   
__future__r   abcr   r   typingr   r   r   r	   r
   r   r   numpyr_   pandas._libs.tslibsr   pandas._typingr   r   r   pandas.util._exceptionsr   pandas.util._validatorsr   pandas.core.dtypes.commonr   r   r   r   r   r   r|   r   pandas.core.reshape.concatr   pandas.io.formats.formatr   r   r   r,   r/   r&   r'   rS   r   r   r   r   rA   r$   r5   r-   r+   <module>r      sN  
 #    ) 
 5 7   - 70"	0" (0" (	0"
 0" 50" 0"fs 4
4. 
4D1 DNF>D
D(D D@-D
-D(-D -D`70!'
!'!' !'H 4 * r-   