HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/io/formats/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/io/formats/__pycache__/info.cpython-36.pyc
3

���h�,�@s�ddlmZmZddlZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZddlmZddlmZddlmZer�dd	lmZe
eefeed
�dd�Ze
eefeed
�dd�ZGdd�ded�ZGdd�de�ZdS)�)�ABCMeta�abstractmethodN)�IO�
TYPE_CHECKING�List�Optional�Tuple�Union)�
get_option)�Dtype�
FrameOrSeries)�Index)�format)�pprint_thing)�Series)�s�space�returncCst|�d|�j|�S)a�
    Make string of specified length, padding to the right if necessary.

    Parameters
    ----------
    s : Union[str, Dtype]
        String to be formatted.
    space : int
        Length to force string to be of.

    Returns
    -------
    str
        String coerced to given length.

    Examples
    --------
    >>> pd.io.formats.info._put_str("panda", 6)
    'panda '
    >>> pd.io.formats.info._put_str("panda", 4)
    'pand'
    N)�str�ljust)rr�r�8/tmp/pip-build-5_djhm0z/pandas/pandas/io/formats/info.py�_put_strsr)�num�size_qualifierrcCsBx0d
D](}|dkr&|d�|�d|��S|d}qW|d�|�d	�S)a{
    Return size in human readable format.

    Parameters
    ----------
    num : int
        Size in bytes.
    size_qualifier : str
        Either empty, or '+' (if lower bound).

    Returns
    -------
    str
        Size in human readable format.

    Examples
    --------
    >>> _sizeof_fmt(23028, '')
    '22.5 KB'

    >>> _sizeof_fmt(23028, '+')
    '22.5+ KB'
    �bytes�KB�MB�GB�TBg�@z3.1f� z PB)rrrrrr)rr�xrrr�_sizeof_fmt,s

r"c	@s�eZdZdeeeeeeeeee	eefeed�dd�Z
eeed�dd��Zee
dd
�dd��Zeeedd	edd
�dd��Zeeeddd�dd��Zdd
�dd�ZdS)�BaseInfoN)�data�verbose�buf�max_cols�memory_usage�null_countscCsF|dkrtj}|dkrtd�}||_||_||_||_||_||_dS)Nzdisplay.memory_usage)	�sys�stdoutr
r$r%r&r'r(r))�selfr$r%r&r'r(r)rrr�__init__Ls	zBaseInfo.__init__)�deeprcCsdS)a�
        Get memory usage in bytes.

        Parameters
        ----------
        deep : bool
            If True, introspect the data deeply by interrogating object dtypes
            for system-level memory consumption, and include it in the returned
            values.

        Returns
        -------
        mem_usage : int
            Object's total memory usage in bytes.
        Nr)r,r.rrr�_get_mem_usageaszBaseInfo._get_mem_usager
r)rcCsdS)z�
        Get column names and dtypes.

        Returns
        -------
        ids : Index
            DataFrame's column names.
        dtypes : Series
            Dtype of each of the DataFrame's columns.
        Nr)r,rrr�_get_ids_and_dtypestszBaseInfo._get_ids_and_dtypes)�lines�ids�dtypes�show_countsrcCsdS)a�
        Append name, non-null count (optional), and dtype for each column to `lines`.

        Parameters
        ----------
        lines : List[str]
            Lines that will contain `info` representation.
        ids : Index
            The DataFrame's column names.
        dtypes : Series
            The DataFrame's columns' dtypes.
        show_counts : bool
            If True, count of non-NA cells for each column will be appended to `lines`.
        Nr)r,r1r2r3r4rrr�
_verbose_repr�szBaseInfo._verbose_repr)r1r2rcCsdS)z�
        Append short summary of columns' names to `lines`.

        Parameters
        ----------
        lines : List[str]
            Lines that will contain `info` representation.
        ids : Index
            The DataFrame's column names.
        Nr)r,r1r2rrr�_non_verbose_repr�szBaseInfo._non_verbose_reprcCs�g}|jtt|j���|j|jjj��|j�\}}t|�}|dkrp|jdt|j�j���t	j
|j|�dS|j}|dkr�t
d|d�}t
dt|j�d�}|jdkr�||ko�t|j�|k}n|j}||k}|jr�|j||||�n>|jdk�r|j||�n$|�r|j||�n|j||||�|j�jdd	��j�}	d
d�t|	j��D�}
|jdd
j|
����|j�r�d}|jdk�r�d}n d}d|	k�s�|jjj��r�d}|j|d�}
|jdt|
|��d��t	j
|j|�dS)a�
        Print a concise summary of a %(klass)s.

        This method prints information about a %(klass)s including
        the index dtype%(type_sub)s, non-null values and memory usage.

        Parameters
        ----------
        data : %(klass)s
            %(klass)s to print information about.
        verbose : bool, optional
            Whether to print the full summary. By default, the setting in
            ``pandas.options.display.max_info_columns`` is followed.
        buf : writable buffer, defaults to sys.stdout
            Where to send the output. By default, the output is printed to
            sys.stdout. Pass a writable buffer if you need to further process
            the output.
        %(max_cols_sub)s
        memory_usage : bool, str, optional
            Specifies whether total memory usage of the %(klass)s
            elements (including the index) should be displayed. By default,
            this follows the ``pandas.options.display.memory_usage`` setting.

            True always show memory usage. False never shows memory usage.
            A value of 'deep' is equivalent to "True with deep introspection".
            Memory usage is shown in human-readable units (base-2
            representation). Without deep introspection a memory estimation is
            made based in column dtype and number of rows assuming values
            consume the same memory amount for corresponding dtypes. With deep
            memory introspection, a real memory usage calculation is performed
            at the cost of computational resources.
        null_counts : bool, optional
            Whether to show the non-null counts. By default, this is shown
            only if the %(klass)s is smaller than
            ``pandas.options.display.max_info_rows`` and
            ``pandas.options.display.max_info_columns``. A value of True always
            shows the counts, and False never shows the counts.

        Returns
        -------
        None
            This method prints a summary of a %(klass)s and returns None.

        See Also
        --------
        %(see_also_sub)s

        Examples
        --------
        %(examples_sub)s
        rzEmpty Nzdisplay.max_info_columns�zdisplay.max_info_rowsFcSs|jS)N)�name)r!rrr�<lambda>�szBaseInfo.info.<locals>.<lambda>cSs&g|]}|d�d|dd�d��qS)r�(r7�d�)r)�.0�krrr�
<listcomp>�sz!BaseInfo.info.<locals>.<listcomp>zdtypes: z, �r.T�object�+)r.zmemory usage: �
)�appendr�typer$�index�_summaryr0�len�__name__�fmtZbuffer_put_linesr&r'r
r)r%r5r6Zvalue_counts�groupby�sum�sorted�items�joinr(Z_is_memory_usage_qualifiedr/r")r,r1r2r3�	col_countr'Zmax_rowsr4Zexceeds_info_cols�countsZcollected_dtypesrr.Z	mem_usagerrr�info�sJ4
z
BaseInfo.info)NNNNN)r
r)rI�
__module__�__qualname__rr�boolrr�intr	r-rr/rr0rr5r6rRrrrrr#Ks:

r#)�	metaclassc@s^eZdZeed�dd�Zedd�dd�Zee	dded	d
�dd�Z
ee	dd	d
�dd�Zd	S)�
DataFrameInfo)r.rcCs|jjd|d�j�S)NT)rFr.)r$r(rL)r,r.rrrr/szDataFrameInfo._get_mem_usager
r)rcCs|jj|jjfS)N)r$�columnsr3)r,rrrr0sz!DataFrameInfo._get_ids_and_dtypesN)r1r2r3r4rc Cs"t|�}|jd|�d��d}d}d}tdd�|D��}	tt|��}
t|	|
�|}tt|��}tt|��}
t||
�|}t||�t||�}|�r|jj�}|t|�kr�td|�d	t|��d
���d}t|�}d}td
d�|D��t|�}t||�|}d|}nd}t|�}|}d}d}t|�}tdd�|D��}t||�}|t||�t||�7}|j|�|jtd|
|�td|
|�td||�td||��x|t|�D]p\}}|j	|}t|�}td|��|�}d}|�r�|j	|}|j|t||�t|j
|d�|�t||���q�WdS)NzData columns (total z
 columns):z # ZColumn�css|]}tt|��VqdS)N)rHr)r=r>rrr�	<genexpr>#sz.DataFrameInfo._verbose_repr.<locals>.<genexpr>zColumns must equal counts (z != r<zNon-Null Countz	 non-nullcss|]}tt|��VqdS)N)rHr)r=r>rrrr[5sz{count}r@rcss|]}tt|��VqdS)N)rHr)r=r>rrrr[@s�-r )�count)rHrD�maxrrr$r]�AssertionError�	enumerateZilocr) r,r1r2r3r4rPZid_headZcolumn_headZ	col_spaceZmax_colZ
len_columnrZmax_idZlen_idZ	space_num�headerrQZcount_headerZ	len_countZnon_null�	max_countZspace_countZ
count_tempZdtype_headerZ	len_dtypeZ
max_dtypesZspace_dtype�i�colZdtypeZline_nor]rrrr5sZ



:

zDataFrameInfo._verbose_repr)r1r2rcCs|j|jdd��dS)NZColumns)r8)rDrG)r,r1r2rrrr6^szDataFrameInfo._non_verbose_repr)r
r)rIrSrTrUrVr/rr0rrr5r6rrrrrXs
CrX) �abcrrr*Ztypingrrrrrr	Zpandas._configr
Zpandas._typingrrZpandas.core.indexes.apir
Zpandas.io.formatsrrJZpandas.io.formats.printingrZpandas.core.seriesrrrVr�floatr"r#rXrrrr�<module>s H