
    cMhm                       d dl mZ d dlmZmZ d dlZd dlmZ d dl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mZ d d
lmZmZ d dlmZmZmZ  ed          Z ed          Z ed          Z ed          Z ddeeee ddZ! ed          Z" ed          Z#dddee"e#ddZ$ ed          Z%dGdZ&dHd#Z'	 dIdJd'Z( G d( d)e          Z) G d* d+e)          Z* G d, d-e)          Z+ G d. d/          Z, G d0 d1e,          Z- G d2 d3e,          Z. G d4 d5e          Z/ G d6 d7e/          Z0 G d8 d9e0          Z1 G d: d;e/          Z2 G d< d=e0e2          Z3 G d> d?e/          Z4 G d@ dAe4          Z5 G dB dCe4e2          Z6dKdFZ7dS )L    )annotations)ABCabstractmethodN)dedent)TYPE_CHECKING
get_option)format)pprint_thing)IterableIteratorMappingSequence)DtypeWriteBuffer)	DataFrameIndexSeriesa      max_cols : int, optional
        When to switch from the verbose to the truncated output. If the
        DataFrame has more than `max_cols` columns, the truncated output
        is used. By default, the setting in
        ``pandas.options.display.max_info_columns`` is used.aR      show_counts : bool, optional
        Whether to show the non-null counts. By default, this is shown
        only if the DataFrame 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.a      >>> int_values = [1, 2, 3, 4, 5]
    >>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']
    >>> float_values = [0.0, 0.25, 0.5, 0.75, 1.0]
    >>> df = pd.DataFrame({"int_col": int_values, "text_col": text_values,
    ...                   "float_col": float_values})
    >>> df
        int_col text_col  float_col
    0        1    alpha       0.00
    1        2     beta       0.25
    2        3    gamma       0.50
    3        4    delta       0.75
    4        5  epsilon       1.00

    Prints information of all columns:

    >>> df.info(verbose=True)
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 5 entries, 0 to 4
    Data columns (total 3 columns):
     #   Column     Non-Null Count  Dtype
    ---  ------     --------------  -----
     0   int_col    5 non-null      int64
     1   text_col   5 non-null      object
     2   float_col  5 non-null      float64
    dtypes: float64(1), int64(1), object(1)
    memory usage: 248.0+ bytes

    Prints a summary of columns count and its dtypes but not per column
    information:

    >>> df.info(verbose=False)
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 5 entries, 0 to 4
    Columns: 3 entries, int_col to float_col
    dtypes: float64(1), int64(1), object(1)
    memory usage: 248.0+ bytes

    Pipe output of DataFrame.info to buffer instead of sys.stdout, get
    buffer content and writes to a text file:

    >>> import io
    >>> buffer = io.StringIO()
    >>> df.info(buf=buffer)
    >>> s = buffer.getvalue()
    >>> with open("df_info.txt", "w",
    ...           encoding="utf-8") as f:  # doctest: +SKIP
    ...     f.write(s)
    260

    The `memory_usage` parameter allows deep introspection mode, specially
    useful for big DataFrames and fine-tune memory optimization:

    >>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)
    >>> df = pd.DataFrame({
    ...     'column_1': np.random.choice(['a', 'b', 'c'], 10 ** 6),
    ...     'column_2': np.random.choice(['a', 'b', 'c'], 10 ** 6),
    ...     'column_3': np.random.choice(['a', 'b', 'c'], 10 ** 6)
    ... })
    >>> df.info()
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 1000000 entries, 0 to 999999
    Data columns (total 3 columns):
     #   Column    Non-Null Count    Dtype
    ---  ------    --------------    -----
     0   column_1  1000000 non-null  object
     1   column_2  1000000 non-null  object
     2   column_3  1000000 non-null  object
    dtypes: object(3)
    memory usage: 22.9+ MB

    >>> df.info(memory_usage='deep')
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 1000000 entries, 0 to 999999
    Data columns (total 3 columns):
     #   Column    Non-Null Count    Dtype
    ---  ------    --------------    -----
     0   column_1  1000000 non-null  object
     1   column_2  1000000 non-null  object
     2   column_3  1000000 non-null  object
    dtypes: object(3)
    memory usage: 165.9 MBz    DataFrame.describe: Generate descriptive statistics of DataFrame
        columns.
    DataFrame.memory_usage: Memory usage of DataFrame columns.r   z and columns )klasstype_submax_cols_subshow_counts_subexamples_subsee_also_subversion_added_suba      >>> int_values = [1, 2, 3, 4, 5]
    >>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']
    >>> s = pd.Series(text_values, index=int_values)
    >>> s.info()
    <class 'pandas.core.series.Series'>
    Index: 5 entries, 1 to 5
    Series name: None
    Non-Null Count  Dtype
    --------------  -----
    5 non-null      object
    dtypes: object(1)
    memory usage: 80.0+ bytes

    Prints a summary excluding information about its values:

    >>> s.info(verbose=False)
    <class 'pandas.core.series.Series'>
    Index: 5 entries, 1 to 5
    dtypes: object(1)
    memory usage: 80.0+ bytes

    Pipe output of Series.info to buffer instead of sys.stdout, get
    buffer content and writes to a text file:

    >>> import io
    >>> buffer = io.StringIO()
    >>> s.info(buf=buffer)
    >>> s = buffer.getvalue()
    >>> with open("df_info.txt", "w",
    ...           encoding="utf-8") as f:  # doctest: +SKIP
    ...     f.write(s)
    260

    The `memory_usage` parameter allows deep introspection mode, specially
    useful for big Series and fine-tune memory optimization:

    >>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)
    >>> s = pd.Series(np.random.choice(['a', 'b', 'c'], 10 ** 6))
    >>> s.info()
    <class 'pandas.core.series.Series'>
    RangeIndex: 1000000 entries, 0 to 999999
    Series name: None
    Non-Null Count    Dtype
    --------------    -----
    1000000 non-null  object
    dtypes: object(1)
    memory usage: 7.6+ MB

    >>> s.info(memory_usage='deep')
    <class 'pandas.core.series.Series'>
    RangeIndex: 1000000 entries, 0 to 999999
    Series name: None
    Non-Null Count    Dtype
    --------------    -----
    1000000 non-null  object
    dtypes: object(1)
    memory usage: 55.3 MBzp    Series.describe: Generate descriptive statistics of Series.
    Series.memory_usage: Memory usage of Series.r   z
.. versionadded:: 1.4.0
a  
    Print a concise summary of a {klass}.

    This method prints information about a {klass} including
    the index dtype{type_sub}, non-null values and memory usage.
    {version_added_sub}
    Parameters
    ----------
    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}
    memory_usage : bool, str, optional
        Specifies whether total memory usage of the {klass}
        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. See the
        :ref:`Frequently Asked Questions <df-memory-usage>` for more
        details.
    {show_counts_sub}

    Returns
    -------
    None
        This method prints a summary of a {klass} and returns None.

    See Also
    --------
    {see_also_sub}

    Examples
    --------
    {examples_sub}
    sstr | Dtypespaceintreturnstrc                V    t          |           d|                             |          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)r"   ljust)r   r   s     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/io/formats/info.py_put_strr&   %  s&    . q66&5&>&&&    numfloatsize_qualifierc                J    dD ]}| dk     r| d| d| c S | dz  } | 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      @z3.1f z PB )r(   r*   xs      r%   _sizeof_fmtr4   ?  s`    0 /  <<444444444v++++++r'   memory_usagebool | str | None
bool | strc                (    | t          d          } | S )z5Get memory usage based on inputs and display options.Nzdisplay.memory_usager   )r5   s    r%   _initialize_memory_usager9   ^  s     !"899r'   c                     e Zd ZU dZded<   ded<   eedd                        Zeedd
                        Zeedd                        Z	eedd                        Z
ed d            Zed d            Zed!d            ZdS )"	_BaseInfoaj  
    Base class for DataFrameInfo and SeriesInfo.

    Parameters
    ----------
    data : DataFrame or Series
        Either dataframe or series.
    memory_usage : bool or str, optional
        If "deep", introspect the data deeply by interrogating object dtypes
        for system-level memory consumption, and include it in the returned
        values.
    DataFrame | Seriesdatar7   r5   r!   Iterable[Dtype]c                    dS )z
        Dtypes.

        Returns
        -------
        dtypes : sequence
            Dtype of each of the DataFrame's columns (or one series column).
        Nr2   selfs    r%   dtypesz_BaseInfo.dtypesx        r'   Mapping[str, int]c                    dS )!Mapping dtype - number of counts.Nr2   r@   s    r%   dtype_countsz_BaseInfo.dtype_counts  rC   r'   Sequence[int]c                    dS )BSequence of non-null counts for all columns or column (if series).Nr2   r@   s    r%   non_null_countsz_BaseInfo.non_null_counts  rC   r'   r    c                    dS )z
        Memory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        Nr2   r@   s    r%   memory_usage_bytesz_BaseInfo.memory_usage_bytes  rC   r'   r"   c                <    t          | j        | j                   dS )z0Memory usage in a form of human readable string.
)r4   rM   r*   r@   s    r%   memory_usage_stringz_BaseInfo.memory_usage_string  s#     d5t7JKKOOOOr'   c                    d}| j         r4| j         dk    r)d| j        v s| j        j                                        rd}|S )Nr   deepobject+)r5   rG   r=   index_is_memory_usage_qualified)rA   r*   s     r%   r*   z_BaseInfo.size_qualifier  sU     		) F**
  111yAACC 2 &)Nr'   bufWriteBuffer[str] | Nonemax_cols
int | Noneverbosebool | Noneshow_countsNonec                   d S Nr2   )rA   rW   rY   r[   r]   s        r%   renderz_BaseInfo.render  s	     	r'   Nr!   r>   r!   rD   r!   rH   r!   r    r!   r"   
rW   rX   rY   rZ   r[   r\   r]   r\   r!   r^   )__name__
__module____qualname____doc____annotations__propertyr   rB   rG   rK   rM   rP   r*   ra   r2   r'   r%   r;   r;   g  sH             ^ X 0 0 0 ^ X0 Q Q Q ^ XQ    ^ X P P P XP    X    ^  r'   r;   c                      e Zd ZdZ	 ddd	Zedd            Zed d            Zed!d            Zed"d            Z	ed#d            Z
ed"d            Zd$dZdS )%DataFrameInfoz0
    Class storing dataframe-specific info.
    Nr=   r   r5   r6   r!   r^   c                <    || _         t          |          | _        d S r`   r=   r9   r5   rA   r=   r5   s      r%   __init__zDataFrameInfo.__init__  s!    
  $	4\BBr'   rD   c                *    t          | j                  S r`   )_get_dataframe_dtype_countsr=   r@   s    r%   rG   zDataFrameInfo.dtype_counts  s    *49555r'   r>   c                    | j         j        S )z
        Dtypes.

        Returns
        -------
        dtypes
            Dtype of each of the DataFrame's columns.
        r=   rB   r@   s    r%   rB   zDataFrameInfo.dtypes  s     yr'   r   c                    | j         j        S )zz
        Column names.

        Returns
        -------
        ids : Index
            DataFrame's column names.
        )r=   columnsr@   s    r%   idszDataFrameInfo.ids  s     y  r'   r    c                *    t          | j                  S z#Number of columns to be summarized.)lenrz   r@   s    r%   	col_countzDataFrameInfo.col_count  s     48}}r'   rH   c                4    | j                                         S )rJ   r=   countr@   s    r%   rK   zDataFrameInfo.non_null_counts  s     y   r'   c                t    | j         dk    }| j                             d|                                          S )NrR   TrU   rR   )r5   r=   sumrA   rR   s     r%   rM   z DataFrameInfo.memory_usage_bytes  s6     F*y%%Dt%<<@@BBBr'   rW   rX   rY   rZ   r[   r\   r]   c               V    t          | |||          }|                    |           d S )N)inforY   r[   r]   )_DataFrameInfoPrinter	to_bufferrA   rW   rY   r[   r]   printers         r%   ra   zDataFrameInfo.render  s@     (#	
 
 
 	#r'   r`   )r=   r   r5   r6   r!   r^   rc   rb   r!   r   re   rd   rg   )rh   ri   rj   rk   rs   rm   rG   rB   rz   r~   rK   rM   ra   r2   r'   r%   ro   ro     s         +/C C C C C 6 6 6 X6 	  	  	  X	  	! 	! 	! X	!    X ! ! ! X! C C C XC     r'   ro   c                      e Zd ZdZ	 ddd	Zddddd
ddZedd            Zedd            Zed d            Z	ed!d            Z
dS )"
SeriesInfoz-
    Class storing series-specific info.
    Nr=   r   r5   r6   r!   r^   c                <    || _         t          |          | _        d S r`   rq   rr   s      r%   rs   zSeriesInfo.__init__  s!    
 !	4\BBr'   )rW   rY   r[   r]   rW   rX   rY   rZ   r[   r\   r]   c               v    |t          d          t          | ||          }|                    |           d S )NzIArgument `max_cols` can only be passed in DataFrame.info, not Series.info)r   r[   r]   )
ValueError_SeriesInfoPrinterr   r   s         r%   ra   zSeriesInfo.render  s\     5   %#
 
 

 	#r'   rH   c                6    | j                                         gS r`   r   r@   s    r%   rK   zSeriesInfo.non_null_counts$  s    	!!""r'   r>   c                    | j         j        gS r`   rw   r@   s    r%   rB   zSeriesInfo.dtypes(  s    	 !!r'   rD   c                H    ddl m} t           || j                            S )Nr   )r   )pandas.core.framer   ru   r=   )rA   r   s     r%   rG   zSeriesInfo.dtype_counts,  s.    //////*99TY+?+?@@@r'   r    c                P    | j         dk    }| j                             d|          S )zMemory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        rR   Tr   )r5   r=   r   s     r%   rM   zSeriesInfo.memory_usage_bytes2  s,      F*y%%Dt%<<<r'   r`   )r=   r   r5   r6   r!   r^   rg   rd   rb   rc   re   )rh   ri   rj   rk   rs   ra   rm   rK   rB   rG   rM   r2   r'   r%   r   r     s          +/C C C C C (,###'     ( # # # X# " " " X" A A A XA
 	= 	= 	= X	= 	= 	=r'   r   c                  4    e Zd ZdZd
ddZedd	            ZdS )_InfoPrinterAbstractz6
    Class for printing dataframe or series info.
    NrW   rX   r!   r^   c                    |                                  }|                                }|t          j        }t	          j        ||           dS )z Save dataframe info into buffer.N)_create_table_builder	get_linessysstdoutfmtbuffer_put_lines)rA   rW   table_builderliness       r%   r   z_InfoPrinterAbstract.to_bufferD  sI    2244''));*CS%(((((r'   _TableBuilderAbstractc                    dS )z!Create instance of table builder.Nr2   r@   s    r%   r   z*_InfoPrinterAbstract._create_table_builderL  rC   r'   r`   )rW   rX   r!   r^   )r!   r   )rh   ri   rj   rk   r   r   r   r2   r'   r%   r   r   ?  sW         ) ) ) ) ) 0 0 0 ^0 0 0r'   r   c                      e Zd ZdZ	 	 	 dddZedd            Zedd            Zedd            Zedd            Z	ddZ
ddZddZdS )r   a{  
    Class for printing dataframe info.

    Parameters
    ----------
    info : DataFrameInfo
        Instance of DataFrameInfo.
    max_cols : int, optional
        When to switch from the verbose to the truncated output.
    verbose : bool, optional
        Whether to print the full summary.
    show_counts : bool, optional
        Whether to show the non-null counts.
    Nr   ro   rY   rZ   r[   r\   r]   r!   r^   c                    || _         |j        | _        || _        |                     |          | _        |                     |          | _        d S r`   )r   r=   r[   _initialize_max_colsrY   _initialize_show_countsr]   )rA   r   rY   r[   r]   s        r%   rs   z_DataFrameInfoPrinter.__init__a  sL     	I	11(;;77DDr'   r    c                L    t          dt          | j                  dz             S )z"Maximum info rows to be displayed.zdisplay.max_info_rows   )r	   r}   r=   r@   s    r%   max_rowsz_DataFrameInfoPrinter.max_rowsn  s"     13ty>>A3EFFFr'   boolc                <    t          | j        | j        k              S )zDCheck if number of columns to be summarized does not exceed maximum.)r   r~   rY   r@   s    r%   exceeds_info_colsz'_DataFrameInfoPrinter.exceeds_info_colss  s     DNT]2333r'   c                V    t          t          | j                  | j        k              S )zACheck if number of rows to be summarized does not exceed maximum.)r   r}   r=   r   r@   s    r%   exceeds_info_rowsz'_DataFrameInfoPrinter.exceeds_info_rowsx  s!     C	NNT]2333r'   c                    | j         j        S r|   r   r~   r@   s    r%   r~   z_DataFrameInfoPrinter.col_count}       y""r'   c                :    |t          d| j        dz             S |S )Nzdisplay.max_info_columnsr   )r	   r~   )rA   rY   s     r%   r   z*_DataFrameInfoPrinter._initialize_max_cols  s%    8$.1:LMMMr'   c                D    |t          | j         o| j                   S |S r`   )r   r   r   rA   r]   s     r%   r   z-_DataFrameInfoPrinter._initialize_show_counts  s-    D22Q4;Q7QRRRr'   _DataFrameTableBuilderc                    | j         rt          | j        | j                  S | j         du rt	          | j                  S | j        rt	          | j                  S t          | j        | j                  S )z[
        Create instance of table builder based on verbosity and display settings.
        r   with_countsFr   )r[   _DataFrameTableBuilderVerboser   r]    _DataFrameTableBuilderNonVerboser   r@   s    r%   r   z+_DataFrameInfoPrinter._create_table_builder  s     < 	0Y ,    \U""3CCCC# 	3CCCC0Y ,   r'   )NNN)
r   ro   rY   rZ   r[   r\   r]   r\   r!   r^   re   r!   r   )rY   rZ   r!   r    r]   r\   r!   r   )r!   r   )rh   ri   rj   rk   rs   rm   r   r   r   r~   r   r   r   r2   r'   r%   r   r   Q  s        $  $##'E E E E E G G G XG 4 4 4 X4 4 4 4 X4 # # # X#   
        r'   r   c                  0    e Zd ZdZ	 	 ddd
ZddZddZdS )r   a  Class for printing series info.

    Parameters
    ----------
    info : SeriesInfo
        Instance of SeriesInfo.
    verbose : bool, optional
        Whether to print the full summary.
    show_counts : bool, optional
        Whether to show the non-null counts.
    Nr   r   r[   r\   r]   r!   r^   c                n    || _         |j        | _        || _        |                     |          | _        d S r`   )r   r=   r[   r   r]   )rA   r   r[   r]   s       r%   rs   z_SeriesInfoPrinter.__init__  s7     	I	77DDr'   _SeriesTableBuilderc                ~    | j         s| j         t          | j        | j                  S t	          | j                  S )zF
        Create instance of table builder based on verbosity.
        Nr   r   )r[   _SeriesTableBuilderVerboser   r]   _SeriesTableBuilderNonVerboser@   s    r%   r   z(_SeriesInfoPrinter._create_table_builder  sM     < 	A4</-Y ,   
 1di@@@@r'   r   c                    |dS |S )NTr2   r   s     r%   r   z*_SeriesInfoPrinter._initialize_show_counts  s    4r'   )NN)r   r   r[   r\   r]   r\   r!   r^   )r!   r   r   )rh   ri   rj   rk   rs   r   r   r2   r'   r%   r   r     sp        
 
  $#'		E 	E 	E 	E 	E
A 
A 
A 
A     r'   r   c                      e Zd ZU dZded<   ded<   edd            Zedd	            Zedd            Z	edd            Z
edd            Zedd            Zedd            Zd dZd dZd dZdS )!r   z*
    Abstract builder for info table.
    	list[str]_linesr;   r   r!   c                    dS )z-Product in a form of list of lines (strings).Nr2   r@   s    r%   r   z_TableBuilderAbstract.get_lines  rC   r'   r<   c                    | j         j        S r`   r   r=   r@   s    r%   r=   z_TableBuilderAbstract.data  s    y~r'   r>   c                    | j         j        S )z*Dtypes of each of the DataFrame's columns.)r   rB   r@   s    r%   rB   z_TableBuilderAbstract.dtypes  s     yr'   rD   c                    | j         j        S )rF   )r   rG   r@   s    r%   rG   z"_TableBuilderAbstract.dtype_counts  s     y%%r'   r   c                4    t          | j        j                  S )z Whether to display memory usage.)r   r   r5   r@   s    r%   display_memory_usagez*_TableBuilderAbstract.display_memory_usage  s     DI*+++r'   r"   c                    | j         j        S )z/Memory usage string with proper size qualifier.)r   rP   r@   s    r%   rP   z)_TableBuilderAbstract.memory_usage_string  s     y,,r'   rH   c                    | j         j        S r`   )r   rK   r@   s    r%   rK   z%_TableBuilderAbstract.non_null_counts  s    y((r'   r^   c                x    | j                             t          t          | j                                       dS )z>Add line with string representation of dataframe to the table.N)r   appendr"   typer=   r@   s    r%   add_object_type_linez*_TableBuilderAbstract.add_object_type_line  s.    3tDI//00000r'   c                r    | j                             | j        j                                                   dS )z,Add line with range of indices to the table.N)r   r   r=   rU   _summaryr@   s    r%   add_index_range_linez*_TableBuilderAbstract.add_index_range_line  s.    49?335566666r'   c                    d t          | j                                                  D             }| j                            dd                    |                      dS )z2Add summary line with dtypes present in dataframe.c                &    g | ]\  }}| d |ddS )(d)r2   ).0keyvals      r%   
<listcomp>z9_TableBuilderAbstract.add_dtypes_line.<locals>.<listcomp>  s=     
 
 
"*#ssS
 
 
r'   zdtypes: z, N)sortedrG   itemsr   r   join)rA   collected_dtypess     r%   add_dtypes_linez%_TableBuilderAbstract.add_dtypes_line  sl    
 
.4T5F5L5L5N5N.O.O
 
 
 	Cdii0@&A&ACCDDDDDr'   Nr!   r   )r!   r<   rb   rc   r   rf   rd   r!   r^   )rh   ri   rj   rk   rl   r   r   rm   r=   rB   rG   r   rP   rK   r   r   r   r2   r'   r%   r   r     sW          OOO< < < ^<    X       X  & & & X& , , , X, - - - X- ) ) ) X)1 1 1 17 7 7 7E E E E E Er'   r   c                      e Zd ZdZddZddZdd	Zedd
            Ze	dd            Z
e	dd            Ze	dd            ZddZdS )r   z
    Abstract builder for dataframe info table.

    Parameters
    ----------
    info : DataFrameInfo.
        Instance of DataFrameInfo.
    r   ro   r!   r^   c                   || _         d S r`   r   rA   r   s     r%   rs   z_DataFrameTableBuilder.__init__  s    #'			r'   r   c                    g | _         | j        dk    r|                                  n|                                  | j         S )Nr   )r   r~   _fill_empty_info_fill_non_empty_infor@   s    r%   r   z _DataFrameTableBuilder.get_lines  sE    >Q!!####%%'''{r'   c                    |                                   |                                  | j                            dt	          | j                  j         d           dS )z;Add lines to the info table, pertaining to empty dataframe.zEmpty rO   N)r   r   r   r   r   r=   rh   r@   s    r%   r   z'_DataFrameTableBuilder._fill_empty_info  sY    !!###!!###@DOO$<@@@AAAAAr'   c                    dS z?Add lines to the info table, pertaining to non-empty dataframe.Nr2   r@   s    r%   r   z+_DataFrameTableBuilder._fill_non_empty_info  rC   r'   r   c                    | j         j        S )z
DataFrame.r   r@   s    r%   r=   z_DataFrameTableBuilder.data#       y~r'   r   c                    | j         j        S )zDataframe columns.)r   rz   r@   s    r%   rz   z_DataFrameTableBuilder.ids(  s     y}r'   r    c                    | j         j        S )z-Number of dataframe columns to be summarized.r   r@   s    r%   r~   z _DataFrameTableBuilder.col_count-  r   r'   c                J    | j                             d| j                    dS z!Add line containing memory usage.zmemory usage: Nr   r   rP   r@   s    r%   add_memory_usage_linez,_DataFrameTableBuilder.add_memory_usage_line2  *    FD,DFFGGGGGr'   N)r   ro   r!   r^   r   r   )r!   r   r   re   )rh   ri   rj   rk   rs   r   r   r   r   rm   r=   rz   r~   r   r2   r'   r%   r   r     s         ( ( ( (   B B B B N N N ^N    X    X # # # X#H H H H H Hr'   r   c                  "    e Zd ZdZddZddZdS )r   z>
    Dataframe info table builder for non-verbose output.
    r!   r^   c                    |                                   |                                  |                                  |                                  | j        r|                                  dS dS r   )r   r   add_columns_summary_liner   r   r   r@   s    r%   r   z5_DataFrameTableBuilderNonVerbose._fill_non_empty_info<  sw    !!###!!###%%'''$ 	)&&(((((	) 	)r'   c                l    | j                             | j                            d                     d S )NColumnsname)r   r   rz   r   r@   s    r%   r   z9_DataFrameTableBuilderNonVerbose.add_columns_summary_lineE  s1    48,,),<<=====r'   Nr   )rh   ri   rj   rk   r   r   r2   r'   r%   r   r   7  sF         ) ) ) )> > > > > >r'   r   c                      e Zd ZU dZdZded<   ded<   ded<   d	ed
<   eedd                        Zedd            Z	ddZ
ddZddZedd            Zedd            Zd dZd dZd dZd!dZd!dZdS )"_TableBuilderVerboseMixinz(
    Mixin for verbose info output.
    z  r"   SPACINGzSequence[Sequence[str]]strrowsrH   gross_column_widthsr   r   r!   Sequence[str]c                    dS ).Headers names of the columns in verbose table.Nr2   r@   s    r%   headersz!_TableBuilderVerboseMixin.headersS  rC   r'   c                $    d | j         D             S )z'Widths of header columns (only titles).c                ,    g | ]}t          |          S r2   r}   r   cols     r%   r   zB_TableBuilderVerboseMixin.header_column_widths.<locals>.<listcomp>[  s    111SC111r'   )r  r@   s    r%   header_column_widthsz._TableBuilderVerboseMixin.header_column_widthsX  s     21DL1111r'   c                h    |                                  }d t          | j        |          D             S )zAGet widths of columns containing both headers and actual content.c                     g | ]}t          | S r2   max)r   widthss     r%   r   zF_TableBuilderVerboseMixin._get_gross_column_widths.<locals>.<listcomp>`  s,     
 
 
 L
 
 
r'   )_get_body_column_widthszipr  )rA   body_column_widthss     r%   _get_gross_column_widthsz2_TableBuilderVerboseMixin._get_gross_column_widths]  sC    !99;;
 
d79KLL
 
 
 	
r'   c                P    t          t          | j                   }d |D             S )z$Get widths of table content columns.c                @    g | ]}t          d  |D                       S )c              3  4   K   | ]}t          |          V  d S r`   r  )r   r3   s     r%   	<genexpr>zO_TableBuilderVerboseMixin._get_body_column_widths.<locals>.<listcomp>.<genexpr>h  s(      ((qCFF((((((r'   r  r  s     r%   r   zE_TableBuilderVerboseMixin._get_body_column_widths.<locals>.<listcomp>h  s/    <<<S((C(((((<<<r'   )listr  r  )rA   strcolss     r%   r  z1_TableBuilderVerboseMixin._get_body_column_widthse  s*    +/T\0B+C+C<<G<<<<r'   Iterator[Sequence[str]]c                `    | j         r|                                 S |                                 S )z
        Generator function yielding rows content.

        Each element represents a row comprising a sequence of strings.
        )r   _gen_rows_with_counts_gen_rows_without_countsr@   s    r%   	_gen_rowsz#_TableBuilderVerboseMixin._gen_rowsj  s3      	3--///00222r'   c                    dS z=Iterator with string representation of body data with counts.Nr2   r@   s    r%   r#  z/_TableBuilderVerboseMixin._gen_rows_with_countsu  rC   r'   c                    dS z@Iterator with string representation of body data without counts.Nr2   r@   s    r%   r$  z2_TableBuilderVerboseMixin._gen_rows_without_countsy  rC   r'   r^   c                    | j                             d t          | j        | j                  D                       }| j                            |           d S )Nc                4    g | ]\  }}t          ||          S r2   r&   )r   header	col_widths      r%   r   z=_TableBuilderVerboseMixin.add_header_line.<locals>.<listcomp>  s6       %FI ++  r'   )r  r   r  r  r  r   r   )rA   header_lines     r%   add_header_linez)_TableBuilderVerboseMixin.add_header_line}  sb    l'' ),T\4;S)T)T  
 
 	;'''''r'   c                    | j                             d t          | j        | j                  D                       }| j                            |           d S )Nc                :    g | ]\  }}t          d |z  |          S )-r,  )r   header_colwidthgross_colwidths      r%   r   z@_TableBuilderVerboseMixin.add_separator_line.<locals>.<listcomp>  s;       3O^ .??  r'   )r  r   r  r  r  r   r   )rA   separator_lines     r%   add_separator_linez,_TableBuilderVerboseMixin.add_separator_line  sh    ** 7:-t/G8 8  
 
 	>*****r'   c                    | j         D ]S}| j                            d t          || j                  D                       }| j                            |           Td S )Nc                4    g | ]\  }}t          ||          S r2   r,  )r   r  r5  s      r%   r   z<_TableBuilderVerboseMixin.add_body_lines.<locals>.<listcomp>  s6       +^ S.11  r'   )r  r  r   r  r  r   r   )rA   row	body_lines      r%   add_body_linesz(_TableBuilderVerboseMixin.add_body_lines  sx    < 	* 	*C)) /238P/Q/Q   I Ky))))	* 	*r'   Iterator[str]c              #  ,   K   | j         D ]	}| dV  
dS )z7Iterator with string representation of non-null counts.z	 non-nullN)rK   )rA   r   s     r%   _gen_non_null_countsz._TableBuilderVerboseMixin._gen_non_null_counts  s:      ) 	& 	&E%%%%%%%	& 	&r'   c              #  @   K   | j         D ]}t          |          V  dS )z5Iterator with string representation of column dtypes.N)rB   r   )rA   dtypes     r%   _gen_dtypesz%_TableBuilderVerboseMixin._gen_dtypes  s8      [ 	& 	&Eu%%%%%%	& 	&r'   Nr!   r  rd   r!   r!  r   r!   r=  )rh   ri   rj   rk   r  rl   rm   r   r  r  r  r  r%  r#  r$  r0  r7  r<  r?  rB  r2   r'   r%   r  r  I  s          G$$$$&&&&= = = ^ X= 2 2 2 X2
 
 
 
= = = =
	3 	3 	3 	3 L L L ^L O O O ^O( ( ( (	+ 	+ 	+ 	+* * * *& & & &
& & & & & &r'   r  c                  b    e Zd ZdZddZdd	Zedd            ZddZddZ	ddZ
ddZddZdS )r   z:
    Dataframe info table builder for verbose output.
    r   ro   r   r   r!   r^   c                   || _         || _        t          |                                           | _        |                                 | _        d S r`   r   r   r  r%  r  r  r  rA   r   r   s      r%   rs   z&_DataFrameTableBuilderVerbose.__init__  F     	&04T^^5E5E0F0F262O2O2Q2Q   r'   c                X   |                                   |                                  |                                  |                                  |                                  |                                  |                                  | j        r|                                  dS dS r   )	r   r   r   r0  r7  r<  r   r   r   r@   s    r%   r   z2_DataFrameTableBuilderVerbose._fill_non_empty_info  s    !!###!!###%%'''!!!$ 	)&&(((((	) 	)r'   r  c                     | j         rg dS g dS )r
  ) # ColumnNon-Null Countr   )rM  rN  r   r   r@   s    r%   r  z%_DataFrameTableBuilderVerbose.headers  s(      	@????))))r'   c                L    | j                             d| j         d           d S )NzData columns (total z
 columns):)r   r   r~   r@   s    r%   r   z6_DataFrameTableBuilderVerbose.add_columns_summary_line  s,    L$.LLLMMMMMr'   r!  c              #     K   t          |                                 |                                 |                                           E d{V  dS r)  )r  _gen_line_numbers_gen_columnsrB  r@   s    r%   r$  z6_DataFrameTableBuilderVerbose._gen_rows_without_counts  sm      ""$$
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r'   c              #     K   t          |                                 |                                 |                                 |                                           E d{V  dS r'  )r  rS  rT  r?  rB  r@   s    r%   r#  z3_DataFrameTableBuilderVerbose._gen_rows_with_counts  s|      ""$$%%''	
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r'   r=  c              #  L   K   t          | j                  D ]\  }}d| V  dS )z6Iterator with string representation of column numbers.r1   N)	enumeraterz   )rA   i_s      r%   rS  z/_DataFrameTableBuilderVerbose._gen_line_numbers  s>      dh'' 	 	DAqa''MMMM	 	r'   c              #  @   K   | j         D ]}t          |          V  dS )z4Iterator with string representation of column names.N)rz   r   )rA   r  s     r%   rT  z*_DataFrameTableBuilderVerbose._gen_columns  s8      8 	$ 	$Cs######	$ 	$r'   N)r   ro   r   r   r!   r^   r   rC  rD  rE  )rh   ri   rj   rk   rs   r   rm   r  r   r$  r#  rS  rT  r2   r'   r%   r   r     s         	R 	R 	R 	R
) 
) 
) 
) * * * X*N N N N
 
 
 

 
 
 
   
$ $ $ $ $ $r'   r   c                  Z    e Zd ZdZddZddZedd
            ZddZe	dd            Z
dS )r   z
    Abstract builder for series info table.

    Parameters
    ----------
    info : SeriesInfo.
        Instance of SeriesInfo.
    r   r   r!   r^   c                   || _         d S r`   r   r   s     r%   rs   z_SeriesTableBuilder.__init__  s     $			r'   r   c                F    g | _         |                                  | j         S r`   )r   r   r@   s    r%   r   z_SeriesTableBuilder.get_lines  s#    !!###{r'   r   c                    | j         j        S )zSeries.r   r@   s    r%   r=   z_SeriesTableBuilder.data  r   r'   c                J    | j                             d| j                    dS r   r   r@   s    r%   r   z)_SeriesTableBuilder.add_memory_usage_line  r   r'   c                    dS z<Add lines to the info table, pertaining to non-empty series.Nr2   r@   s    r%   r   z(_SeriesTableBuilder._fill_non_empty_info  rC   r'   N)r   r   r!   r^   r   )r!   r   r   )rh   ri   rj   rk   rs   r   rm   r=   r   r   r   r2   r'   r%   r   r     s         % % % %   
    XH H H H K K K ^K K Kr'   r   c                      e Zd ZdZddZdS )r   z;
    Series info table builder for non-verbose output.
    r!   r^   c                    |                                   |                                  |                                  | j        r|                                  dS dS ra  )r   r   r   r   r   r@   s    r%   r   z2_SeriesTableBuilderNonVerbose._fill_non_empty_info  se    !!###!!###$ 	)&&(((((	) 	)r'   Nr   )rh   ri   rj   rk   r   r2   r'   r%   r   r     s2         ) ) ) ) ) )r'   r   c                  R    e Zd ZdZddZdd	Zdd
Zedd            ZddZ	ddZ
dS )r   z7
    Series info table builder for verbose output.
    r   r   r   r   r!   r^   c                   || _         || _        t          |                                           | _        |                                 | _        d S r`   rH  rI  s      r%   rs   z#_SeriesTableBuilderVerbose.__init__  rJ  r'   c                X   |                                   |                                  |                                  |                                  |                                  |                                  |                                  | j        r|                                  dS dS ra  )	r   r   add_series_name_liner0  r7  r<  r   r   r   r@   s    r%   r   z/_SeriesTableBuilderVerbose._fill_non_empty_info&  s    !!###!!###!!###!!!$ 	)&&(((((	) 	)r'   c                T    | j                             d| j        j                    d S )NzSeries name: )r   r   r=   r  r@   s    r%   rg  z/_SeriesTableBuilderVerbose.add_series_name_line2  s+    ;49>;;<<<<<r'   r  c                    | j         rddgS dgS )r
  rO  r   rP  r@   s    r%   r  z"_SeriesTableBuilderVerbose.headers5  s"      	/$g..yr'   r!  c              #  >   K   |                                  E d{V  dS r)  )rB  r@   s    r%   r$  z3_SeriesTableBuilderVerbose._gen_rows_without_counts<  s0      ##%%%%%%%%%%%r'   c              #  ~   K   t          |                                 |                                           E d{V  dS r'  )r  r?  rB  r@   s    r%   r#  z0_SeriesTableBuilderVerbose._gen_rows_with_counts@  s^      %%''
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r'   N)r   r   r   r   r!   r^   r   rC  rD  )rh   ri   rj   rk   rs   r   rg  rm   r  r$  r#  r2   r'   r%   r   r     s         	R 	R 	R 	R
) 
) 
) 
)= = = =    X& & & &
 
 
 
 
 
r'   r   dfrD   c                    | j                                                             d                                           S )zK
    Create mapping between datatypes and their number of occurrences.
    c                    | j         S r`   r  )r3   s    r%   <lambda>z-_get_dataframe_dtype_counts.<locals>.<lambda>M  s    af r'   )rB   value_countsgroupbyr   )rl  s    r%   ru   ru   H  s6    
 9!!##++,<,<==AACCCr'   )r   r   r   r    r!   r"   )r(   r)   r*   r"   r!   r"   r`   )r5   r6   r!   r7   )rl  r   r!   rD   )8
__future__r   abcr   r   r   textwrapr   typingr   pandas._configr	   pandas.io.formatsr
   r   pandas.io.formats.printingr   collections.abcr   r   r   r   pandas._typingr   r   pandasr   r   r   frame_max_cols_subr   frame_examples_subframe_see_also_subframe_sub_kwargsseries_examples_subseries_see_also_subseries_sub_kwargsINFO_DOCSTRINGr&   r4   r9   r;   ro   r   r   r   r   r   r   r   r  r   r   r   r   ru   r2   r'   r%   <module>r     sF   " " " " " "        


                   % % % % % % + + + + + + 3 3 3 3 3 3                   
          V@   &?  VQS S l VB   &&&&   f9; ; | f4   &''6   .0 0f' ' ' '4, , , ,@ '+    P P P P P P P PfF F F F FI F F FR9= 9= 9= 9= 9= 9= 9= 9=x0 0 0 0 0 0 0 0$M M M M M0 M M M`( ( ( ( (- ( ( (V5E 5E 5E 5E 5EC 5E 5E 5Ep0H 0H 0H 0H 0H2 0H 0H 0Hf> > > > >'= > > >$Z& Z& Z& Z& Z& 5 Z& Z& Z&z?$ ?$ ?$ ?$ ?$$:<U ?$ ?$ ?$DK K K K K/ K K K@) ) ) ) )$7 ) ) )/
 /
 /
 /
 /
!46O /
 /
 /
dD D D D D Dr'   