
    hMh
                     "    d Z ddlZddZddZdS )z Utility functions for missingno.    Ncolumnsc           	         || S |dvrt          d          |dvrt          d          |dk    r|dk    r<| j        t          j        |                     d          j                  ddf         S |d	k    rN| j        t          j        t          j        |                     d          j                            ddf         S dS |d
k    r|dk    r<| j        ddt          j        |                     d
          j                  f         S |d	k    rP| j        ddt          j        t          j        |                     d
          j                            f         S dS dS )a  
    Sorts a DataFrame according to its nullity, in either ascending or descending order.

    :param df: The DataFrame object being sorted.
    :param sort: The sorting method: either "ascending", "descending", or None (default).
    :return: The nullity-sorted DataFrame.
    N)	ascending
descendingz@The "sort" parameter must be set to "ascending" or "descending".)rowsr   z8The "axis" parameter must be set to "rows" or "columns".r   r   axisr   r   )
ValueErrorilocnpargsortcountvaluesflipud)dfsortr	   s      O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/missingno/utils.pynullity_sortr      sv    |		0	0	0[\\\&&&STTTy;72:bhhIh&>&>&EFFIJJ\!!729RZi0H0H0O%P%PQQSTSTSTTUU "!	;7111bjv)>)>)EFFFGG\!!7111bi
28883H3H3O(P(PQQQRR	 
 "!    c           	         |dk    rrF| j         ddfd|                     d          j        t          |           z  D             f         } |rW| j         ddt	          j        t	          j        |                     d          j                  | d                   f         } n|dk    rrF| j         ddfd|                     d          j        t          |           z  D             f         } |rV| j         ddt	          j        t	          j        |                     d          j                  d|                   f         } | S )a  
    Filters a DataFrame according to its nullity, using some combination of 'top' and 'bottom' numerical and
    percentage values. Percentages and numerical thresholds can be specified simultaneously: for example,
    to get a DataFrame with columns of at least 75% completeness but with no more than 5 columns, use
    `nullity_filter(df, filter='top', p=.75, n=5)`.

    :param df: The DataFrame whose columns are being filtered.
    :param filter: The orientation of the filter being applied to the DataFrame. One of, "top", "bottom",
    or None (default). The filter will simply return the DataFrame if you leave the filter argument unspecified or
    as None.
    :param p: A completeness ratio cut-off. If non-zero the filter will limit the DataFrame to columns with at least p
    completeness. Input should be in the range [0, 1].
    :param n: A numerical cut-off. If non-zero no more than this number of columns will be returned.
    :return: The nullity-filtered `DataFrame`.
    topNc                     g | ]}|k    	S  r   .0cps     r   
<listcomp>z"nullity_filter.<locals>.<listcomp>3       TTTQ!VTTTr   r   r   bottomc                     g | ]}|k    	S r   r   r   s     r   r   z"nullity_filter.<locals>.<listcomp>8   r   r   )r   r   r   lenr   r   r   )r   filterr   ns     ` r   nullity_filterr%   !   sY      	VTTTTRXX6X-B-B-ICPRGG-STTTTUB 	TBGBJrxxVx/D/D/K$L$LaRSS$QRRRSB	8		 	VTTTTRXX6X-B-B-ICPRGG-STTTTUB 	SBGBJrxxVx/D/D/K$L$LRaR$PQQQRBIr   )Nr   )Nr   r   )__doc__numpyr   r   r%   r   r   r   <module>r(      sM    & &    S S S S8     r   