
    Owgm                       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%d9dZ&d:dZ'	 d;	 	 	 d<dZ( G d de      Z) G d de)      Z* G d  d!e)      Z+ G d" d#      Z, G d$ d%e,      Z- G d& d'e,      Z. G d( d)e      Z/ G d* d+e/      Z0 G d, d-e0      Z1 G d. d/e/      Z2 G d0 d1e0e2      Z3 G d2 d3e/      Z4 G d4 d5e4      Z5 G d6 d7e4e2      Z6d=d8Z7y)>    )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}
    c                <    t        |       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)sspaces     M/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/io/formats/info.py_put_strr#   %  s    . q6&5>&&    c                L    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 )numsize_qualifierxs      r"   _sizeof_fmtr0   ?  sQ    0 / <$Z/q44v $Z's++r$   c                     | t        d      } | S )z5Get memory usage based on inputs and display options.zdisplay.memory_usager   )memory_usages    r"   _initialize_memory_usager3   ^  s     !"8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y)	_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data
bool | strr2   c                     y)z
        Dtypes.

        Returns
        -------
        dtypes : sequence
            Dtype of each of the DataFrame's columns (or one series column).
        Nr,   selfs    r"   dtypesz_BaseInfo.dtypesx      r$   c                     y)!Mapping dtype - number of counts.Nr,   r:   s    r"   dtype_countsz_BaseInfo.dtype_counts  r=   r$   c                     y)BSequence of non-null counts for all columns or column (if series).Nr,   r:   s    r"   non_null_countsz_BaseInfo.non_null_counts  r=   r$   c                     y)z
        Memory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        Nr,   r:   s    r"   memory_usage_bytesz_BaseInfo.memory_usage_bytes  r=   r$   c                H    t        | j                  | j                         dS )z0Memory usage in a form of human readable string.
)r0   rE   r.   r:   s    r"   memory_usage_stringz_BaseInfo.memory_usage_string  s%     d55t7J7JKLBOOr$   c                    d}| j                   rC| j                   dk7  r4d| j                  v s$| j                  j                  j	                         rd}|S )Nr   deepobject+)r2   r@   r7   index_is_memory_usage_qualified)r;   r.   s     r"   r.   z_BaseInfo.size_qualifier  sM      F*
  1 11yyAAC%(Nr$   c                    y Nr,   )r;   bufmax_colsverboseshow_countss        r"   renderz_BaseInfo.render  s     	r$   NreturnzIterable[Dtype]rW   Mapping[str, int]rW   Sequence[int]rW   intrW   r   
rQ   WriteBuffer[str] | NonerR   
int | NonerS   bool | NonerT   rb   rW   None)__name__
__module____qualname____doc____annotations__propertyr   r<   r@   rC   rE   rH   r.   rU   r,   r$   r"   r5   r5   g  s        0  0 Q  Q    P P    % 	
  ! 
 r$   r5   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y)DataFrameInfoz0
    Class storing dataframe-specific info.
    Nc                2    || _         t        |      | _        y rP   r7   r3   r2   r;   r7   r2   s      r"   __init__zDataFrameInfo.__init__  s    
  $	4\Br$   c                ,    t        | j                        S rP   )_get_dataframe_dtype_countsr7   r:   s    r"   r@   zDataFrameInfo.dtype_counts  s    *49955r$   c                .    | j                   j                  S )z
        Dtypes.

        Returns
        -------
        dtypes
            Dtype of each of the DataFrame's columns.
        r7   r<   r:   s    r"   r<   zDataFrameInfo.dtypes  s     yyr$   c                .    | j                   j                  S )zz
        Column names.

        Returns
        -------
        ids : Index
            DataFrame's column names.
        )r7   columnsr:   s    r"   idszDataFrameInfo.ids  s     yy   r$   c                ,    t        | j                        S z#Number of columns to be summarized.)lenrv   r:   s    r"   	col_countzDataFrameInfo.col_count  s     488}r$   c                6    | j                   j                         S )rB   r7   countr:   s    r"   rC   zDataFrameInfo.non_null_counts  s     yy  r$   c                v    | j                   dk(  }| j                  j                  d|      j                         S )NrJ   TrM   rJ   )r2   r7   sumr;   rJ   s     r"   rE   z DataFrameInfo.memory_usage_bytes  s5      F*yy%%Dt%<@@BBr$   c               D    t        | |||      }|j                  |       y )N)inforR   rS   rT   )_DataFrameInfoPrinter	to_bufferr;   rQ   rR   rS   rT   printers         r"   rU   zDataFrameInfo.render  s*     (#	
 	#r$   rP   )r7   r   r2   bool | str | NonerW   rc   rX   rV   rW   r   r\   rZ   r_   )rd   re   rf   rg   ro   ri   r@   r<   rv   rz   rC   rE   rU   r,   r$   r"   rk   rk     s     +/CC (C 
	C 6 6 	  	  	! 	!   ! ! C C % 	
  ! 
r$   rk   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
y)
SeriesInfoz-
    Class storing series-specific info.
    Nc                2    || _         t        |      | _        y rP   rm   rn   s      r"   ro   zSeriesInfo.__init__  s    
 !	4\Br$   )rQ   rR   rS   rT   c               \    |t        d      t        | ||      }|j                  |       y )NzIArgument `max_cols` can only be passed in DataFrame.info, not Series.info)r   rS   rT   )
ValueError_SeriesInfoPrinterr   r   s         r"   rU   zSeriesInfo.render  sA     5  %#

 	#r$   c                8    | j                   j                         gS rP   r|   r:   s    r"   rC   zSeriesInfo.non_null_counts$  s    		!""r$   c                0    | j                   j                  gS rP   rs   r:   s    r"   r<   zSeriesInfo.dtypes(  s    		  !!r$   c                D    ddl m} t         || j                              S )Nr   )r   )pandas.core.framer   rq   r7   )r;   r   s     r"   r@   zSeriesInfo.dtype_counts,  s    /*9TYY+?@@r$   c                Z    | j                   dk(  }| j                  j                  d|      S )zMemory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        rJ   Tr   )r2   r7   r   s     r"   rE   zSeriesInfo.memory_usage_bytes2  s.       F*yy%%Dt%<<r$   rP   )r7   r   r2   r   rW   rc   r_   rZ   rV   rX   r\   )rd   re   rf   rg   ro   rU   ri   rC   r<   r@   rE   r,   r$   r"   r   r     s     +/CC (C 
	C (,###' % 	
  ! 
( # # " " A A
 	= 	=r$   r   c                  ,    e Zd ZdZdddZedd       Zy)_InfoPrinterAbstractz6
    Class for printing dataframe or series info.
    Nc                    | j                         }|j                         }|t        j                  }t	        j
                  ||       y)z Save dataframe info into buffer.N)_create_table_builder	get_linessysstdoutfmtbuffer_put_lines)r;   rQ   table_builderliness       r"   r   z_InfoPrinterAbstract.to_bufferD  s<    224'');**CS%(r$   c                     y)z!Create instance of table builder.Nr,   r:   s    r"   r   z*_InfoPrinterAbstract._create_table_builderL  r=   r$   rP   )rQ   r`   rW   rc   )rW   _TableBuilderAbstract)rd   re   rf   rg   r   r   r   r,   r$   r"   r   r   ?  s     ) 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y)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.
    Nc                    || _         |j                  | _        || _        | j                  |      | _        | j                  |      | _        y rP   )r   r7   rS   _initialize_max_colsrR   _initialize_show_countsrT   )r;   r   rR   rS   rT   s        r"   ro   z_DataFrameInfoPrinter.__init__a  sB     	II	11(;77Dr$   c                F    t        dt        | j                        dz         S )z"Maximum info rows to be displayed.zdisplay.max_info_rows   )r	   ry   r7   r:   s    r"   max_rowsz_DataFrameInfoPrinter.max_rowsn  s     13tyy>A3EFFr$   c                F    t        | j                  | j                  kD        S )zDCheck if number of columns to be summarized does not exceed maximum.)boolrz   rR   r:   s    r"   exceeds_info_colsz'_DataFrameInfoPrinter.exceeds_info_colss  s     DNNT]]233r$   c                X    t        t        | j                        | j                  kD        S )zACheck if number of rows to be summarized does not exceed maximum.)r   ry   r7   r   r:   s    r"   exceeds_info_rowsz'_DataFrameInfoPrinter.exceeds_info_rowsx  s      C		NT]]233r$   c                .    | j                   j                  S rx   r   rz   r:   s    r"   rz   z_DataFrameInfoPrinter.col_count}       yy"""r$   c                <    |t        d| j                  dz         S |S )Nzdisplay.max_info_columnsr   )r	   rz   )r;   rR   s     r"   r   z*_DataFrameInfoPrinter._initialize_max_cols  s$    8$..1:LMMr$   c                T    |%t        | j                   xr | j                         S |S rP   )r   r   r   r;   rT   s     r"   r   z-_DataFrameInfoPrinter._initialize_show_counts  s0    D222Q4;Q;Q7QRRr$   c                *   | 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   )rS   _DataFrameTableBuilderVerboser   rT    _DataFrameTableBuilderNonVerboser   r:   s    r"   r   z+_DataFrameInfoPrinter._create_table_builder  sz     <<0YY ,,  \\U"3CC##3CC0YY ,, r$   )NNN)
r   rk   rR   ra   rS   rb   rT   rb   rW   rc   r\   rW   r   )rR   ra   rW   r]   rT   rb   rW   r   )rW   _DataFrameTableBuilder)rd   re   rf   rg   ro   ri   r   r   r   rz   r   r   r   r,   r$   r"   r   r   Q  s    $  $##'EE E 	E
 !E 
E G G 4 4 4 4 # #
r$   r   c                  <    e Zd ZdZ	 	 d	 	 	 	 	 	 	 ddZddZd	dZy)
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.
    Nc                n    || _         |j                  | _        || _        | j                  |      | _        y rP   )r   r7   rS   r   rT   )r;   r   rS   rT   s       r"   ro   z_SeriesInfoPrinter.__init__  s0     	II	77Dr$   c                    | j                   s| j                   !t        | j                  | j                        S t	        | j                        S )zF
        Create instance of table builder based on verbosity.
        r   r   )rS   _SeriesTableBuilderVerboser   rT   _SeriesTableBuilderNonVerboser:   s    r"   r   z(_SeriesInfoPrinter._create_table_builder  sB     <<4<</-YY ,, 
 1dii@@r$   c                    |y|S )NTr,   r   s     r"   r   z*_SeriesInfoPrinter._initialize_show_counts  s    r$   )NN)r   r   rS   rb   rT   rb   rW   rc   )rW   _SeriesTableBuilderr   )rd   re   rf   rg   ro   r   r   r,   r$   r"   r   r     sJ    
  $#'		E	E 	E !		E
 
	E
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y)r   z*
    Abstract builder for info table.
    	list[str]_linesr5   r   c                     y)z-Product in a form of list of lines (strings).Nr,   r:   s    r"   r   z_TableBuilderAbstract.get_lines  r=   r$   c                .    | j                   j                  S rP   r   r7   r:   s    r"   r7   z_TableBuilderAbstract.data  s    yy~~r$   c                .    | j                   j                  S )z*Dtypes of each of the DataFrame's columns.)r   r<   r:   s    r"   r<   z_TableBuilderAbstract.dtypes  s     yyr$   c                .    | j                   j                  S )r?   )r   r@   r:   s    r"   r@   z"_TableBuilderAbstract.dtype_counts  s     yy%%%r$   c                @    t        | j                  j                        S )z Whether to display memory usage.)r   r   r2   r:   s    r"   display_memory_usagez*_TableBuilderAbstract.display_memory_usage  s     DII**++r$   c                .    | j                   j                  S )z/Memory usage string with proper size qualifier.)r   rH   r:   s    r"   rH   z)_TableBuilderAbstract.memory_usage_string  s     yy,,,r$   c                .    | j                   j                  S rP   )r   rC   r:   s    r"   rC   z%_TableBuilderAbstract.non_null_counts  s    yy(((r$   c                r    | j                   j                  t        t        | j                                     y)z>Add line with string representation of dataframe to the table.N)r   appendr   typer7   r:   s    r"   add_object_type_linez*_TableBuilderAbstract.add_object_type_line  s!    3tDII/0r$   c                ~    | j                   j                  | j                  j                  j	                                y)z,Add line with range of indices to the table.N)r   r   r7   rM   _summaryr:   s    r"   add_index_range_linez*_TableBuilderAbstract.add_index_range_line  s%    499??3356r$   c                    t        | j                  j                               D cg c]  \  }}| d|dd }}}| j                  j	                  ddj                  |              yc c}}w )z2Add summary line with dtypes present in dataframe.(d)zdtypes: z, N)sortedr@   itemsr   r   join)r;   keyvalcollected_dtypess       r"   add_dtypes_linez%_TableBuilderAbstract.add_dtypes_line  sq     /5T5F5F5L5L5N.O
"*#sse1SG1
 
 	Xdii0@&A%BCD
s   A+NrW   r   )rW   r6   rV   rX   r   r^   rZ   rW   rc   )rd   re   rf   rg   rh   r   r   ri   r7   r<   r@   r   rH   rC   r   r   r   r,   r$   r"   r   r     s     
O< <       & & , , - - ) )17Er$   r   c                  x    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y
)r   z
    Abstract builder for dataframe info table.

    Parameters
    ----------
    info : DataFrameInfo.
        Instance of DataFrameInfo.
    c                   || _         y rP   r   r;   r   s     r"   ro   z_DataFrameTableBuilder.__init__  s	    #'	r$   c                    g | _         | j                  dk(  r| j                          | j                   S | j                          | j                   S )Nr   )r   rz   _fill_empty_info_fill_non_empty_infor:   s    r"   r   z _DataFrameTableBuilder.get_lines  sE    >>Q!!# {{ %%'{{r$   c                    | j                          | j                          | j                  j                  dt	        | j
                        j                   d       y)z;Add lines to the info table, pertaining to empty dataframe.zEmpty rG   N)r   r   r   r   r   r7   rd   r:   s    r"   r   z'_DataFrameTableBuilder._fill_empty_info  sD    !!#!!#VDO$<$<#=R@Ar$   c                     yz?Add lines to the info table, pertaining to non-empty dataframe.Nr,   r:   s    r"   r   z+_DataFrameTableBuilder._fill_non_empty_info  r=   r$   c                .    | j                   j                  S )z
DataFrame.r   r:   s    r"   r7   z_DataFrameTableBuilder.data#       yy~~r$   c                .    | j                   j                  S )zDataframe columns.)r   rv   r:   s    r"   rv   z_DataFrameTableBuilder.ids(  s     yy}}r$   c                .    | j                   j                  S )z-Number of dataframe columns to be summarized.r   r:   s    r"   rz   z _DataFrameTableBuilder.col_count-  r   r$   c                T    | j                   j                  d| j                          yz!Add line containing memory usage.zmemory usage: Nr   r   rH   r:   s    r"   add_memory_usage_linez,_DataFrameTableBuilder.add_memory_usage_line2  "    ^D,D,D+EFGr$   N)r   rk   rW   rc   r   r   )rW   r   r   r\   )rd   re   rf   rg   ro   r   r   r   r   ri   r7   rv   rz   r   r,   r$   r"   r   r     so    (B N N     # #Hr$   r   c                       e Zd ZdZddZddZy)r   z>
    Dataframe info table builder for non-verbose output.
    c                    | j                          | j                          | j                          | j                          | j                  r| j                          yyr   )r   r   add_columns_summary_liner   r   r   r:   s    r"   r   z5_DataFrameTableBuilderNonVerbose._fill_non_empty_info<  sL    !!#!!#%%'$$&&( %r$   c                n    | j                   j                  | j                  j                  d             y )NColumnsname)r   r   rv   r   r:   s    r"   r   z9_DataFrameTableBuilderNonVerbose.add_columns_summary_lineE  s&    488,,),<=r$   Nr   )rd   re   rf   rg   r   r   r,   r$   r"   r   r   7  s    )>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y)_TableBuilderVerboseMixinz(
    Mixin for verbose info output.
    z  r   SPACINGzSequence[Sequence[str]]strrowsr[   gross_column_widthsr   r   c                     y).Headers names of the columns in verbose table.Nr,   r:   s    r"   headersz!_TableBuilderVerboseMixin.headersS  r=   r$   c                R    | j                   D cg c]  }t        |       c}S c c}w )z'Widths of header columns (only titles).)r  ry   r;   cols     r"   header_column_widthsz._TableBuilderVerboseMixin.header_column_widthsX  s      %)LL1SC111s   $c                    | j                         }t        | j                  |      D cg c]
  }t        |  c}S c c}w )zAGet widths of columns containing both headers and actual content.)_get_body_column_widthszipr  max)r;   body_column_widthswidthss      r"   _get_gross_column_widthsz2_TableBuilderVerboseMixin._get_gross_column_widths]  sE    !99; d779KL
 L
 	
 
s   ;c                    t        t        | j                         }|D cg c]  }t        d |D               c}S c c}w )z$Get widths of table content columns.c              3  2   K   | ]  }t        |        y wrP   )ry   ).0r/   s     r"   	<genexpr>zD_TableBuilderVerboseMixin._get_body_column_widths.<locals>.<genexpr>h  s     (qCF(s   )listr  r   r  )r;   strcolsr  s      r"   r
  z1_TableBuilderVerboseMixin._get_body_column_widthse  s4    +/T\\0B+C4;<S(C((<<<s   <c                Z    | j                   r| j                         S | j                         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  s+     --//0022r$   c                     yz=Iterator with string representation of body data with counts.Nr,   r:   s    r"   r  z/_TableBuilderVerboseMixin._gen_rows_with_countsu  r=   r$   c                     yz@Iterator with string representation of body data without counts.Nr,   r:   s    r"   r  z2_TableBuilderVerboseMixin._gen_rows_without_countsy  r=   r$   c           
         | j                   j                  t        | j                  | j                        D cg c]  \  }}t        ||       c}}      }| j                  j                  |       y c c}}w rP   )r   r   r  r  r  r#   r   r   )r;   header	col_widthheader_lines       r"   add_header_linez)_TableBuilderVerboseMixin.add_header_line}  sc    ll'' *-T\\4;S;S)T%FI +
 	;'s   A3
c           
         | j                   j                  t        | j                  | j                        D cg c]  \  }}t        d|z  |       c}}      }| j                  j                  |       y c c}}w )N-)r   r   r  r  r  r#   r   r   )r;   header_colwidthgross_colwidthseparator_lines       r"   add_separator_linez,_TableBuilderVerboseMixin.add_separator_line  sm    ** 8;--t/G/G83O^ .?
 	>*s   A6
c                    | j                   D ]i  }| j                  j                  t        || j                        D cg c]  \  }}t        ||       c}}      }| j                  j                  |       k y c c}}w rP   )r   r   r   r  r  r#   r   r   )r;   rowr  r&  	body_lines        r"   add_body_linesz(_TableBuilderVerboseMixin.add_body_lines  sr    << 	*C)) 0338P8P/Q+^ S.1I KKy)	*s   A:c              #  <   K   | j                   D ]	  }| d  yw)z7Iterator with string representation of non-null counts.z	 non-nullN)rC   )r;   r}   s     r"   _gen_non_null_countsz._TableBuilderVerboseMixin._gen_non_null_counts  s(     )) 	&EG9%%	&s   c              #  H   K   | j                   D ]  }t        |        yw)z5Iterator with string representation of column dtypes.N)r<   r   )r;   dtypes     r"   _gen_dtypesz%_TableBuilderVerboseMixin._gen_dtypes  s$     [[ 	&Eu%%	&    "NrW   zSequence[str]rZ   rW   zIterator[Sequence[str]]r   rW   zIterator[str])rd   re   rf   rg   r   rh   ri   r   r  r  r  r
  r  r  r  r"  r(  r,  r.  r1  r,   r$   r"   r   r   I  s     GS$$&&=  = 2 2
=
	3 L L O O(	+*&
&r$   r   c                  f    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y
)r   z:
    Dataframe info table builder for verbose output.
    c                   || _         || _        t        | j                               | _        | j                         | _        y rP   r   r   r  r  r   r  r  r;   r   r   s      r"   ro   z&_DataFrameTableBuilderVerbose.__init__  7     	&04T^^5E0F262O2O2Q r$   c                   | j                          | j                          | j                          | j                          | j	                          | j                          | j                          | j                  r| j                          yyr   )	r   r   r   r"  r(  r,  r   r   r   r:   s    r"   r   z2_DataFrameTableBuilderVerbose._fill_non_empty_info  sp    !!#!!#%%'!$$&&( %r$   c                *    | j                   rg dS g dS )r  ) # ColumnNon-Null Countr   )r=  r>  r   r   r:   s    r"   r  z%_DataFrameTableBuilderVerbose.headers  s     ??))r$   c                V    | j                   j                  d| j                   d       y )NzData columns (total z
 columns):)r   r   rz   r:   s    r"   r   z6_DataFrameTableBuilderVerbose.add_columns_summary_line  s#    1$..1ALMr$   c              #     K   t        | j                         | j                         | j                               E d{    y7 wr  )r  _gen_line_numbers_gen_columnsr1  r:   s    r"   r  z6_DataFrameTableBuilderVerbose._gen_rows_without_counts  s<     ""$
 	
 	
s   ;AAAc              #     K   t        | j                         | j                         | j                         | j	                               E d{    y7 wr  )r  rC  rD  r.  r1  r:   s    r"   r  z3_DataFrameTableBuilderVerbose._gen_rows_with_counts  sH     ""$%%'	
 	
 	
s   A
AAAc              #  T   K   t        | j                        D ]  \  }}d|   yw)z6Iterator with string representation of column numbers.r+   N)	enumeraterv   )r;   i_s      r"   rC  z/_DataFrameTableBuilderVerbose._gen_line_numbers  s-     dhh' 	DAqaS'M	s   &(c              #  H   K   | j                   D ]  }t        |        yw)z4Iterator with string representation of column names.N)rv   r   r  s     r"   rD  z*_DataFrameTableBuilderVerbose._gen_columns  s$     88 	$Cs##	$r2  N)r   rk   r   r   rW   rc   r   r3  r4  r5  )rd   re   rf   rg   ro   r   ri   r  r   r  r  rC  rD  r,   r$   r"   r   r     sa    	R 	R 		R
 
	R
) * *N


$r$   r   c                  L    e Zd ZdZddZd	dZed
d       ZddZe	dd       Z
y)r   z
    Abstract builder for series info table.

    Parameters
    ----------
    info : SeriesInfo.
        Instance of SeriesInfo.
    c                   || _         y rP   r   r   s     r"   ro   z_SeriesTableBuilder.__init__  s	     $	r$   c                H    g | _         | j                          | j                   S rP   )r   r   r:   s    r"   r   z_SeriesTableBuilder.get_lines  s    !!#{{r$   c                .    | j                   j                  S )zSeries.r   r:   s    r"   r7   z_SeriesTableBuilder.data  r   r$   c                T    | j                   j                  d| j                          yr   r   r:   s    r"   r   z)_SeriesTableBuilder.add_memory_usage_line  r   r$   c                     yz<Add lines to the info table, pertaining to non-empty series.Nr,   r:   s    r"   r   z(_SeriesTableBuilder._fill_non_empty_info  r=   r$   N)r   r   rW   rc   r   )rW   r   r   )rd   re   rf   rg   ro   r   ri   r7   r   r   r   r,   r$   r"   r   r     sA    %
  H K Kr$   r   c                      e Zd ZdZddZy)r   z;
    Series info table builder for non-verbose output.
    c                    | j                          | j                          | j                          | j                  r| j	                          yyrQ  )r   r   r   r   r   r:   s    r"   r   z2_SeriesTableBuilderNonVerbose._fill_non_empty_info  s@    !!#!!#$$&&( %r$   Nr   )rd   re   rf   rg   r   r,   r$   r"   r   r     s    )r$   r   c                  V    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
y)r   z7
    Series info table builder for verbose output.
    c                   || _         || _        t        | j                               | _        | j                         | _        y rP   r8  r9  s      r"   ro   z#_SeriesTableBuilderVerbose.__init__  r:  r$   c                   | j                          | j                          | j                          | j                          | j	                          | j                          | j                          | j                  r| j                          yyrQ  )	r   r   add_series_name_liner"  r(  r,  r   r   r   r:   s    r"   r   z/_SeriesTableBuilderVerbose._fill_non_empty_info&  sp    !!#!!#!!#!$$&&( %r$   c                h    | j                   j                  d| j                  j                          y )NzSeries name: )r   r   r7   r   r:   s    r"   rW  z/_SeriesTableBuilderVerbose.add_series_name_line2  s$    ]499>>*:;<r$   c                (    | j                   rddgS dgS )r  r?  r   r@  r:   s    r"   r  z"_SeriesTableBuilderVerbose.headers5  s      $g..yr$   c              #  @   K   | j                         E d{    y7 wr  )r1  r:   s    r"   r  z3_SeriesTableBuilderVerbose._gen_rows_without_counts<  s     ##%%%s   c              #  p   K   t        | j                         | j                               E d{    y7 wr  )r  r.  r1  r:   s    r"   r  z0_SeriesTableBuilderVerbose._gen_rows_with_counts@  s0     %%'
 	
 	
s   ,646N)r   r   r   r   rW   rc   r   r3  r4  )rd   re   rf   rg   ro   r   rW  ri   r  r  r  r,   r$   r"   r   r     sV    	R 	R 		R
 
	R
)=  &
r$   r   c                r    | j                   j                         j                  d       j                         S )zK
    Create mapping between datatypes and their number of occurrences.
    c                    | j                   S rP   r   )r/   s    r"   <lambda>z-_get_dataframe_dtype_counts.<locals>.<lambda>M  s
    aff r$   )r<   value_countsgroupbyr   )dfs    r"   rq   rq   H  s,    
 99!!#++,<=AACCr$   )r    zstr | Dtyper!   r]   rW   r   )r-   floatr.   r   rW   r   rP   )r2   r   rW   r8   )ra  r   rW   rY   )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#   r0   r3   r5   rk   r   r   r   r   r   r   r   r   r   r   r   r   rq   r,   r$   r"   <module>ru     s   "     % + 3 
  @  ? QS l B  &&&&  9; | 4  &''6  .0f'4,@ '+#P PfFI FR9= 9=x0 0$M0 M`(- (V5EC 5Ep0H2 0Hf>'= >$Z& 5 Z&z?$$:<U ?$DK/ K@)$7 )/
!46O /
dDr$   