
    i:)                    v   d Z ddlmZ ddlmZmZ ddl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mZmZ dd
lmZ ddlmZ ddlmZ erddlmZm Z m!Z! 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Z,	 	 	 	 d!dZ-	 	 	 	 d"dZ.y)#z
Module responsible for execution of NDFrame.describe() method.

Method NDFrame.describe() delegates actual execution to function describe_ndframe().
    )annotations)ABCabstractmethod)TYPE_CHECKINGcastN)DtypeObjNDFrameTnpt)validate_percentile)is_bool_dtypeis_numeric_dtype)
ArrowDtypeDatetimeTZDtypeExtensionDtype)Float64Dtype)concat)format_percentiles)CallableHashableSequence)	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``.
    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   objr   )r   includeexclude)percentiles)_refine_percentilesndimSeriesDescriberr   DataFrameDescriberdescriber	   )r   r   r   r   	describerresults         Y/app/cer_product_mecsu/.venv/lib/python3.12/site-packages/pandas/core/methods/describe.pydescribe_ndframer(   7   sm    8 &k2K xx1}#Xs#
	 '[#&
	 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.
    c                    || _         y Nr   )selfr   s     r'   __init__z!NDFrameDescriberAbstract.__init__n   s	    r)   c                     y)zDo describe either series or dataframe.

        Parameters
        ----------
        percentiles : list-like of numbers
            The percentiles to include in the output.
        N )r.   r   s     r'   r$   z!NDFrameDescriberAbstract.describeq   s    r)   N)r   DataFrame | SeriesreturnNone)r   Sequence[float] | np.ndarrayr3   r2   )__name__
__module____qualname____doc__r/   r   r$   r1   r)   r'   r+   r+   e   s       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                R    t        | j                        } || j                  |      S r-   )select_describe_funcr   )r.   r   describe_funcs      r'   r$   zSeriesDescriber.describe   s&    ,HH
 TXX{33r)   N)r   r5   r3   r   )r6   r7   r8   r9   __annotations__r$   r1   r)   r'   r"   r"   |   s    <	K4r)   r"   c                  P     e Zd ZU dZded<   	 	 	 	 	 	 	 	 d fdZddZd	dZ xZS )
r#   ab  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.
    r   r   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!   columnssize
ValueErrorsuperr/   )r.   r   r   r   	__class__s       r'   r/   zDataFrameDescriber.__init__   sH     88q=S[[--2JKKr)   c                V   | j                         }g }|j                         D ](  \  }}t        |      }|j                   |||             * t	        |      }t        |D cg c]  }|j                  |       c}ddd      }	|j                  j                         |	_        |	S c c}w )Nr   TF)axisignore_indexsort)	_select_dataitemsr<   appendreorder_columnsr   reindexrB   copy)
r.   r   dataldesc_seriesr=   	col_namesxds
             r'   r$   zDataFrameDescriber.describe   s      "  	=IAv08MLLv{;<	= $E*	+01aQYYy!1	
 LL%%'	 2s   "B&c                   | j                   `| j                  Tt        j                  dg}| j                  j                  |      }t        |j                        dk(  r| j                  }|S | j                   dk(  r'| j                  d}t        |      | j                  }|S | j                  j                  | j                   | j                        }t        |j                        dk(  rd}t        |      |S )zSelect columns to be described.datetime)r   r   allz*exclude must be None when include is 'all')r   r   z<No columns match the specified include or exclude data types)	r   r   npnumberr   select_dtypeslenrB   rD   )r.   default_includerQ   msgs       r'   rK   zDataFrameDescriber._select_data   s    LL t||';46IIz3JO88))/)BD4<< A%xx  \\U"||'B o%88D  88)) * D 4<< A%T o%r)   )r   r   r   str | Sequence[str] | Noner   ra   r3   r4   )r   r5   r3   r   )r3   r   )	r6   r7   r8   r9   r>   r/   r$   rK   __classcell__)rF   s   @r'   r#   r#      sD    
 
N ,	
 , 
$r)   r#   c                    g }t               }t        d | D        t              }|D ]0  }|D ])  }||vs|j                  |       |j	                  |       + 2 |S )z,Set a convenient order for rows for display.c              3  4   K   | ]  }|j                     y wr-   )index).0rV   s     r'   	<genexpr>z"reorder_columns.<locals>.<genexpr>   s     3AGG3s   )key)setsortedr^   addrM   )rR   names
seen_namesldesc_indexesidxnamesnames         r'   rN   rN      se    E #J3U3=M! # 	#D:%t$T"	##
 Lr)   c                   ddl m} t        |      }t        |      dk(  rg }n| j	                  |      j                         }ddddg|d}| j                         | j                         | j                         | j                         g|| j                         }t        | j                  t              r_t        | j                  t              r:| j                  j                  dk(  rd	}nYdd	l}t        |j#                               }n;t%               }n0| j                  j                  d
v r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mNiufbfloatre   rp   dtype)pandasr   r   r^   quantiletolistrs   rt   ru   rv   rw   
isinstancer|   r   r   kindpyarrowfloat64r   r[   rp   )	rT   r   r   formatted_percentiles	quantiles
stat_indexrW   r|   pas	            r'   describe_numeric_1dr      s"    .{;
;1	OOK0779	65%O2GOOJ



		
 
	 	

	A &,,/fllJ/||  C'$"2::<0 NE			f	$!!: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.
    )rs   uniquetopfreqr   Nobjectrr   r{   )
value_countsr^   re   ilocr[   nanrs   r}   r   rp   )
rQ   percentiles_ignoredrl   	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l m} t        |      }dddg|d}| j                         | j	                         | j                         g| j                  |      j                         | j                         } |||| 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   rr   rs   rt   rv   rw   )re   rp   )
r}   r   r   rs   rt   rv   r~   r   rw   rp   )rQ   r   r   r   r   rW   s         r'   describe_timestamp_1dr   .  s     .{;65H+@H%HJ

		
	 
{	#	*	*	,		
 	
	A !:DII66r)   c                   t        | j                        rt        S t        |       rt        S | j                  j
                  dk(  st        | j                  t              rt        S | j                  j
                  dk(  rt        S t        S )zSelect proper function for describing series based on data type.

    Parameters
    ----------
    data : Series
        Series to be described.
    Mrx   )	r   r|   r   r   r   r   r   r   r   )rQ   s    r'   r<   r<   H  sc     TZZ &&	$	""	C	:djj/#J$$	C	""&&r)   c                    | t        j                  g d      S t        j                  |       } t        |        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      ?g      ?z%percentiles cannot contain duplicates)r[   arrayasarrayr   r   r^   rD   )r   unique_pctss     r'   r    r    ^  sr     xx)****[)K $ ))K(K"""
;#k**@AAr)   )
r   r	   r   ra   r   ra   r   #Sequence[float] | np.ndarray | Noner3   r	   )rR   zSequence[Series]r3   zlist[Hashable])rT   r   r   Sequence[float]r3   r   )rQ   r   r   r   r3   r   )rQ   r   r   r   r3   r   )rQ   r   r3   r   )r   r   r3   znpt.NDArray[np.float64])/r9   
__future__r   abcr   r   typingr   r   numpyr[   pandas._typingr   r	   r
   pandas.util._validatorsr   pandas.core.dtypes.commonr   r   pandas.core.dtypes.dtypesr   r   r   pandas.core.arrays.floatingr   pandas.core.reshape.concatr   pandas.io.formats.formatr   collections.abcr   r   r   r}   r   r   r(   r+   r"   r#   rN   r   r   r   r<   r    r1   r)   r'   <module>r      s   #
  
 8  5 - 7 +"	+" (+" (	+"
 5+" +"\s .	4. 	4E1 EP
.FbD
D(D D@74'
'',4r)   