
    Pi:)                    Z   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)d0d%Z*d1d(Z+d2d)Z,d3d+Z-d4d-Z.dS )5z
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Seriesobjr	   includestr | Sequence[str] | Noneexcludepercentiles#Sequence[float] | np.ndarray | Nonereturnc                
   t          |          }| j        dk    rt          t          d|                     }n t	          t          d|           ||          }|                    |          }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   r   r   )r   r   r   )r   )_refine_percentilesndimSeriesDescriberr   DataFrameDescriberdescriber	   )r   r   r   r   	describerresults         p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/core/methods/describe.pydescribe_ndframer+   7   s    8 &k22K x1}}#Xs##
 
 
		 '[#&&
 
 
	 K88F&!!!    c                  2    e Zd ZdZddZedd	            Zd
S )NDFrameDescriberAbstractzAbstract class for describing dataframe or series.

    Parameters
    ----------
    obj : Series or DataFrame
        Object to be described.
    r   DataFrame | Seriesr   Nonec                    || _         d S Nr"   )selfr   s     r*   __init__z!NDFrameDescriberAbstract.__init__n   s    r,   r   Sequence[float] | np.ndarrayc                    dS )zDo describe either series or dataframe.

        Parameters
        ----------
        percentiles : list-like of numbers
            The percentiles to include in the output.
        N )r3   r   s     r*   r'   z!NDFrameDescriberAbstract.describeq   s      r,   N)r   r/   r   r0   )r   r5   r   r/   )__name__
__module____qualname____doc__r4   r   r'   r7   r,   r*   r.   r.   e   sR                ^  r,   r.   c                  &    e Zd ZU dZded<   d	dZdS )
r%   z2Class responsible for creating series description.r   r   r   r5   r   c                L    t          | j                  } || j        |          S r2   )select_describe_funcr   )r3   r   describe_funcs      r*   r'   zSeriesDescriber.describe   s,    ,H
 
 }TX{333r,   N)r   r5   r   r   )r8   r9   r:   r;   __annotations__r'   r7   r,   r*   r%   r%   |   s9         <<KKK4 4 4 4 4 4r,   r%   c                  @     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   r   r   r   r   r0   c                   || _         || _        |j        dk    r|j        j        dk    rt          d          t                                          |           d S )N   r   z+Cannot describe a DataFrame without columns)r   r   r$   columnssize
ValueErrorsuperr4   )r3   r   r   r   	__class__s       r*   r4   zDataFrameDescriber.__init__   sZ     8q==S[-22JKKKr,   r   r5   c                \   |                                  }g }|                                D ]3\  }}t          |          }|                     |||                     4t	          |          t          fd|D             ddd          }|j                                        |_        |S )Nc                :    g | ]}|                               S r7   )reindex).0x	col_namess     r*   
<listcomp>z/DataFrameDescriber.describe.<locals>.<listcomp>   s%    111aQYYy!!111r,   r!   TF)axisignore_indexsort)_select_dataitemsr>   appendreorder_columnsr   rD   copy)	r3   r   dataldesc_seriesr?   drN   s	           @r*   r'   zDataFrameDescriber.describe   s      ""  	= 	=IAv088MLLv{;;<<<<#E**	11115111	
 
 
 L%%''	r,   c                   | j         P| j        It          j        dg}| j                            |          }t          |j                  dk    r| j        }nz| j         dk    r | j        d}t          |          | j        }nO| j                            | j         | j                  }t          |j                  dk    rd}t          |          |S )	zSelect columns to be described.N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lenrD   rF   )r3   default_includerX   msgs       r*   rS   zDataFrameDescriber._select_data   s    L t|';46Iz3JO8))/)BBD4<  A%%x\U""|'B oo%8DD8)) *  D 4<  A%%T oo%r,   )r   r   r   r   r   r   r   r0   )r   r5   r   r   )r   r   )	r8   r9   r:   r;   r@   r4   r'   rS   __classcell__)rH   s   @r*   r&   r&      s|         
 
 NNN        $       r,   r&   rY   Sequence[Series]list[Hashable]c                    g }t                      }t          d | D             t                    }|D ]5}|D ]0}||vr*|                    |           |                    |           16|S )z,Set a convenient order for rows for display.c              3  $   K   | ]}|j         V  d S r2   )index)rL   rM   s     r*   	<genexpr>z"reorder_columns.<locals>.<genexpr>   s$      33AG333333r,   )key)setsortedrc   addrU   )rY   names
seen_namesldesc_indexesidxnamesnames         r*   rV   rV      s    E #J33U333===M! # # 	# 	#D:%%t$$$T"""	# Lr,   r[   r   Sequence[float]c                   ddl m} t          |          }t          |          dk    rg }n'|                     |                                          }ddddg|d}|                                 |                                 |                                 | 	                                g|| 
                                }t          | j        t                    rbt          | j        t                    r9| j        j        dk    rd	}nZdd	l}t          |                                          }n4t%                      }n%| 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rk   ru   dtype)pandasr   r   rc   quantiletolistry   rz   r{   r|   r}   
isinstancer   r   r   kindpyarrowfloat64r   r`   ru   )	r[   r   r   formatted_percentiles	quantiles
stat_indexr\   r   pas	            r*   describe_numeric_1dr      ss    .{;;
;1		OOK007799	65%O2GOOJ



		
 
	 	

	A &,// flJ// 		#| C''$$$$"2::<<00 NNEE		f	$	$!!6!:FKuEEEEr,   rX   percentiles_ignoredc                B   g d}|                                  }t          ||dk                       }|dk    r|j        d         |j        d         }}d}nt          j        t          j        }}d}|                                 |||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.
    )ry   uniquetopfreqr   Nobjectrx   r   )
value_countsrc   rk   ilocr`   nanry   r   r   ru   )
rX   r   rq   	objcountscount_uniquer   r   r   r)   r   s
             r*   describe_categorical_1dr     s     /..E!!##Iya011LaOA&	q(9T FBFTjjllL#t4F6&DIUCCCCr,   c                P   ddl m} t          |          }dddg|d}|                                 |                                 |                                 g|                     |                                          |                                 } |||| 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   rx   ry   rz   r|   r}   )rk   ru   )
r   r   r   ry   rz   r|   r   r   r}   ru   )rX   r   r   r   r   r\   s         r*   describe_timestamp_1dr   .  s     .{;;65H+@H%HJ

		

	 
{	#	#	*	*	,	,		
 	

	A 6!:DI6666r,   r   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.
    Mr~   )	r   r   r   r   r   r   r   r   r   )rX   s    r*   r>   r>   H  ss     TZ   	'&&	$		 '""	C		:dj/#J#J	$$	C		""&&r,   npt.NDArray[np.float64]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.
    N)g      ?g      ?g      ?z%percentiles cannot contain duplicates)r`   arrayasarrayr   r   rc   rF   )r   unique_pctss     r*   r#   r#   ^  s     x)))****[))K $$$ )K((K"""
;#k****@AAAr,   )
r   r	   r   r   r   r   r   r   r   r	   )rY   rg   r   rh   )r[   r   r   rv   r   r   )rX   r   r   rv   r   r   )rX   r   r   rv   r   r   )rX   r   r   r   )r   r   r   r   )/r;   
__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&   rV   r   r   r   r>   r#   r7   r,   r*   <module>r      s    # " " " " "              
             
 8 7 7 7 7 7                 5 4 4 4 4 4 - - - - - - 7 7 7 7 7 7 
                +" +" +" +"\    s   .	4 	4 	4 	4 	4. 	4 	4 	4E E E E E1 E E EP
 
 
 
.F .F .F .FbD D D D@7 7 7 74' ' ' ',     r,   