1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
U
¬ý°d/ã@sšdZddlmZddlmZmZddlmZmZm    Z    m
Z
m Z m Z ddl ZddlmZddlmZmZmZddlmZdd    lmZmZmZmZmZmZdd
lmZdd l m!Z!dd l"m#Z#dd l$m%Z%erØddl&m'Z'm(Z(ddddddœdd„Z)Gdd„deƒZ*Gdd„de*ƒZ+Gdd„de*ƒZ,dddœdd„Z-d d!d d"œd#d$„Z.d d!d d%œd&d'„Z/d d!d d%œd(d)„Z0d d!d d*œd+d,„Z1d d-d.œd/d0„Z2dd1d2œd3d4„Z3dS)5z–
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)Úvalidate_percentile)Ú is_bool_dtypeÚis_complex_dtypeÚis_datetime64_any_dtypeÚis_extension_array_dtypeÚis_numeric_dtypeÚis_timedelta64_dtype)Ú
ArrowDtype)Ú Float64Dtype)Úconcat)Úformat_percentiles)Ú    DataFrameÚSeriesr ústr | Sequence[str] | Nonez#Sequence[float] | np.ndarray | None)ÚobjÚincludeÚexcludeÚ percentilesÚreturncCsNt|ƒ}|jdkr$ttd|ƒd}nttd|ƒ||d}|j|d}tt|ƒ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©rr)rrr)r )Úrefine_percentilesÚndimÚSeriesDescriberr
ÚDataFrameDescriberÚdescriber )rrrr Z    describerÚresult©r*úSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/methods/describe.pyÚdescribe_ndframe5s
ÿý r,c@s4eZdZdZdddœdd„Zedddœd    d
„ƒZd S) ÚNDFrameDescriberAbstractz”Abstract class for describing dataframe or series.
 
    Parameters
    ----------
    obj : Series or DataFrame
        Object to be described.
    zDataFrame | SeriesÚNone)rr!cCs
||_dS©Nr#)Úselfrr*r*r+Ú__init__lsz!NDFrameDescriberAbstract.__init__úSequence[float] | np.ndarray©r r!cCsdS)z¸Do describe either series or dataframe.
 
        Parameters
        ----------
        percentiles : list-like of numbers
            The percentiles to include in the output.
        Nr*)r0r r*r*r+r(osz!NDFrameDescriberAbstract.describeN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r1rr(r*r*r*r+r-csr-c@s*eZdZUdZded<dddœdd„ZdS)    r&z2Class responsible for creating series description.rrr2r3cCst|jƒ}||j|ƒSr/)Úselect_describe_funcr)r0r Ú describe_funcr*r*r+r(sÿzSeriesDescriber.describeN)r4r5r6r7Ú__annotations__r(r*r*r*r+r&zs
r&csDeZdZdZdddddœ‡fdd„ Zddd    œd
d „Zd d „Z‡ZS)r'abClass 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.
    rrr.)rrrr!cs:||_||_|jdkr*|jjdkr*tdƒ‚tƒ |¡dS)Nérz+Cannot describe a DataFrame without columns)rrr%ÚcolumnsÚsizeÚ
ValueErrorÚsuperr1)r0rrr©Ú    __class__r*r+r1“s
zDataFrameDescriber.__init__r2r3csj| ¡}g}| ¡D] \}}t|ƒ}| |||ƒ¡qt|ƒ‰t‡fdd„|Dƒddd}|j ¡|_|S)Ncsg|]}|jˆdd‘qS)F)Úcopy)Zreindex©Ú.0Úx©Z    col_namesr*r+Ú
<listcomp>¬sz/DataFrameDescriber.describe.<locals>.<listcomp>r"F)ZaxisÚsort)Ú _select_dataÚitemsr8ÚappendÚreorder_columnsrr<rB)r0r ÚdataÚldescÚ_Úseriesr9Údr*rFr+r(¢sý zDataFrameDescriber.describecCs‚|jdkrB|jdkrBtjdg}|jj|d}t|jƒdkr~|j}n<|jdkrj|jdk    rbd}t|ƒ‚|j}n|jj|j|jd}|S)zSelect columns to be described.NÚdatetime)rrÚallz*exclude must be None when include is 'all')rr)    rrÚnpÚnumberrZ select_dtypesÚlenr<r>)r0Zdefault_includerMÚmsgr*r*r+rI³s
 
 
þzDataFrameDescriber._select_data)r4r5r6r7r1r(rIÚ __classcell__r*r*r@r+r'†s r'zSequence[Series]zlist[Hashable])rNr!cCsDg}tdd„|Dƒtd}|D] }|D]}||kr&| |¡q&q|S)z,Set a convenient order for rows for display.css|] }|jVqdSr/)ÚindexrCr*r*r+Ú    <genexpr>Ësz"reorder_columns.<locals>.<genexpr>)Úkey)ÚsortedrVrK)rNÚnamesZ ldesc_indexesZidxnamesÚnamer*r*r+rLÈsrLrzSequence[float])rPr r!cCsÂddlm}t|ƒ}ddddg|dg}| ¡| ¡| ¡| ¡g| |¡ ¡|     ¡g}t
|ƒrt |j t ƒrˆddl}t | ¡ƒ}q°tƒ}n t|ƒr¬t|ƒs¬t  d    ¡}nd}||||j|d
S) zÛDescribe 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ÚmaxNÚfloat©rYr^Údtype)Úpandasrrr`rarbrcÚquantileÚtolistrdrÚ
isinstancergrZpyarrowÚfloat64rrrrTr^)rPr rÚformatted_percentilesÚ
stat_indexrQÚpargr*r*r+Údescribe_numeric_1dÓs$
 ÿþÿ  rp)rMÚpercentiles_ignoredr!c
Csˆddddg}| ¡}t||dkƒ}|dkrH|jd|jd}}d}ntjtj}}d}| ¡|||g}ddlm}    |    |||j    |d    S)
zãDescribe series containing categorical data.
 
    Parameters
    ----------
    data : Series
        Series to be described.
    percentiles_ignored : list-like of numbers
        Ignored, but in place to unify interface.
    r`ÚuniqueÚtopÚfreqrNÚobjectr_rf)
Ú value_countsrVrYÚilocrTÚnanr`rhrr^)
rMrqr]Ú    objcountsÚ count_uniquersrtrgr)rr*r*r+Údescribe_categorical_1d÷s  r{c Csddg}| ¡}t||dkƒ}| ¡|g}d}|dkrÐ|jd|jd}}|jj}    | ¡j     d¡}
t
|ƒ}|j dk    rŒ|    dk    rŒ|  |    ¡}n
|  |    ¡}|dddd    g7}|||t
|
 ¡|    d
t
|
 ¡|    d
g7}n |ddg7}|tjtjg7}d }dd lm} | |||j|d S)zøDescribe 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.
    r`rrrNÚi8rsrtÚfirstÚlast)Útzrur_rf)rvrVr`rYrwÚdtrZdropnaÚvaluesÚviewr ÚtzinfoZ
tz_convertZ tz_localizercrdrTrxrhrr^) rMrqr]ryrzr)rgrsrtrZasintrr*r*r+Ú$describe_timestamp_as_categorical_1ds2   
ü
 r„)rMr r!cCsfddlm}t|ƒ}dddg|dg}| ¡| ¡| ¡g| |¡ ¡| ¡g}||||j    dS)zÛDescribe series containing datetime64 dtype.
 
    Parameters
    ----------
    data : Series
        Series to be described.
    percentiles : list-like of numbers
        The percentiles to include in the output.
    rr_r`rarcrd)rYr^)
rhrrr`rarcrirjrdr^)rMr rrmrnrQr*r*r+Údescribe_timestamp_1dGs  ÿþÿr…r)rMr!cCs>t|jƒrtSt|ƒrtSt|jƒr(tSt|jƒr6tStSdS)z–Select proper function for describing series based on data type.
 
    Parameters
    ----------
    data : Series
        Series to be described.
    N)rrgr{rrprr…r)rMr*r*r+r8_s
 
 
 
r8z%np.ndarray[Any, np.dtype[np.float64]]r3cCsv|dkrt dddg¡St|ƒ}t|ƒd|kr:| d¡t |¡}t |¡}|dk    sZt‚t|ƒt|ƒkrrt    dƒ‚|S)zº
    Ensure that percentiles are unique and sorted.
 
    Parameters
    ----------
    percentiles : list-like of numbers, optional
        The percentiles to include in the output.
    NgÐ?gà?gè?z%percentiles cannot contain duplicates)
rTÚarrayÚlistrrKZasarrayrrÚAssertionErrorrVr>)r Z unique_pctsr*r*r+r$us 
 
 
 r$)4r7Ú
__future__rÚabcrrÚtypingrrrrr    r
ÚnumpyrTZpandas._libs.tslibsr Zpandas._typingr r rZpandas.util._validatorsrZpandas.core.dtypes.commonrrrrrrZpandas.core.arrays.arrow.dtyperZpandas.core.arrays.floatingrZpandas.core.reshape.concatrZpandas.io.formats.formatrrhrrr,r-r&r'rLrpr{r„r…r8r$r*r*r*r+Ú<module>s2                 . B $ 0