
    aVg              	         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	m
Z
mZmZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ e	r
d d
lmZmZmZ  ed      Z ed      Z ed      Z ed      Z ed      Z ddeeeee ddZ! ed      Z" ed      Z#ddded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IterableIteratorMappingSequence
get_option)DtypeWriteBuffer)format)pprint_thing)	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.zd
    null_counts : bool, optional
        .. deprecated:: 1.2.0
            Use show_counts instead.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null_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'>
    Int64Index: 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'>
    Int64Index: 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}{null_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     W/var/www/html/hubwallet-dev/venv/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_fmtr1   G  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_usager4   f  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 | strr3   c                     y)z
        Dtypes.

        Returns
        -------
        dtypes : sequence
            Dtype of each of the DataFrame's columns (or one series column).
        Nr-   selfs    r#   dtypeszBaseInfo.dtypes      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.
)r1   rF   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+)r3   rA   r8   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]rX   Mapping[str, int]rX   Sequence[int]rX   intrX   r   
rR   WriteBuffer[str] | NonerS   
int | NonerT   bool | NonerU   rc   rX   None)__name__
__module____qualname____doc____annotations__propertyr   r=   rA   rD   rF   rI   r/   rV   r-   r%   r#   r6   r6   o  s        0  0 Q  Q    P P    % 	
  ! 
 r%   r6   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 rQ   r8   r4   r3   r<   r8   r3   s      r#   __init__zDataFrameInfo.__init__  s    
  $	4\Br%   c                ,    t        | j                        S rQ   )_get_dataframe_dtype_countsr8   r;   s    r#   rA   zDataFrameInfo.dtype_counts  s    *49955r%   c                .    | j                   j                  S )z
        Dtypes.

        Returns
        -------
        dtypes
            Dtype of each of the DataFrame's columns.
        r8   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.
        )r8   columnsr;   s    r#   idszDataFrameInfo.ids  s     yy   r%   c                ,    t        | j                        S z#Number of columns to be summarized.)lenrw   r;   s    r#   	col_countzDataFrameInfo.col_count  s     488}r%   c                6    | j                   j                         S )rC   r8   countr;   s    r#   rD   zDataFrameInfo.non_null_counts  s     yy  r%   c                    | j                   dk(  rd}nd}| j                  j                  d|      j                         S )NrK   TFrN   rK   )r3   r8   sumr<   rK   s     r#   rF   z DataFrameInfo.memory_usage_bytes  s=    &DDyy%%Dt%<@@BBr%   c               D    t        | |||      }|j                  |       y )N)inforS   rT   rU   )DataFrameInfoPrinter	to_bufferr<   rR   rS   rT   rU   printers         r#   rV   zDataFrameInfo.render  s*     '#	
 	#r%   rQ   )r8   r   r3   bool | str | NonerX   rd   rY   rW   rX   r   r]   r[   r`   )re   rf   rg   rh   rp   rj   rA   r=   rw   r{   rD   rF   rV   r-   r%   r#   rl   rl     s     +/CC (C 
	C 6 6 	  	  	! 	!   ! ! C C % 	
  ! 
r%   rl   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 rQ   rn   ro   s      r#   rp   zSeriesInfo.__init__  s    
 !	4\Br%   )rR   rS   rT   rU   c               \    |t        d      t        | ||      }|j                  |       y )NzIArgument `max_cols` can only be passed in DataFrame.info, not Series.info)r   rT   rU   )
ValueErrorSeriesInfoPrinterr   r   s         r#   rV   zSeriesInfo.render  sA     5  $#

 	#r%   c                8    | j                   j                         gS rQ   r}   r;   s    r#   rD   zSeriesInfo.non_null_counts/  s    		!""r%   c                0    | j                   j                  gS rQ   rt   r;   s    r#   r=   zSeriesInfo.dtypes3  s    		  !!r%   c                D    ddl m} t         || j                              S )Nr   )r   )pandas.core.framer   rr   r8   )r<   r   s     r#   rA   zSeriesInfo.dtype_counts7  s    /*9TYY+?@@r%   c                d    | j                   dk(  rd}nd}| j                  j                  d|      S )zMemory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        rK   TFr   )r3   r8   r   s     r#   rF   zSeriesInfo.memory_usage_bytes=  s6     &DDyy%%Dt%<<r%   rQ   )r8   r   r3   r   rX   rd   r`   r[   rW   rY   r]   )re   rf   rg   rh   rp   rV   rj   rD   r=   rA   rF   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<   rR   table_builderliness       r#   r   zInfoPrinterAbstract.to_bufferR  s<    224'');**CS%(r%   c                     y)z!Create instance of table builder.Nr-   r;   s    r#   r   z)InfoPrinterAbstract._create_table_builderZ  r>   r%   rQ   )rR   ra   rX   rd   )rX   TableBuilderAbstract)re   rf   rg   rh   r   r   r   r-   r%   r#   r   r   M  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 rQ   )r   r8   rT   _initialize_max_colsrS   _initialize_show_countsrU   )r<   r   rS   rT   rU   s        r#   rp   zDataFrameInfoPrinter.__init__o  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   rz   r8   r;   s    r#   max_rowszDataFrameInfoPrinter.max_rows|  s     13tyy>A3EFFr%   c                F    t        | j                  | j                  kD        S )zDCheck if number of columns to be summarized does not exceed maximum.)boolr{   rS   r;   s    r#   exceeds_info_colsz&DataFrameInfoPrinter.exceeds_info_cols  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   rz   r8   r   r;   s    r#   exceeds_info_rowsz&DataFrameInfoPrinter.exceeds_info_rows  s      C		NT]]233r%   c                .    | j                   j                  S ry   r   r{   r;   s    r#   r{   zDataFrameInfoPrinter.col_count       yy"""r%   c                <    |t        d| j                  dz         S |S )Nzdisplay.max_info_columnsr   )r   r{   )r<   rS   s     r#   r   z)DataFrameInfoPrinter._initialize_max_cols  s$    8$..1:LMMr%   c                T    |%t        | j                   xr | j                         S |S rQ   )r   r   r   r<   rU   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   )rT   DataFrameTableBuilderVerboser   rU   DataFrameTableBuilderNonVerboser   r;   s    r#   r   z*DataFrameInfoPrinter._create_table_builder  sz     <</YY ,,  \\U"2		BB%%6DIIFF3 $ 0 0 r%   )NNN)
r   rl   rS   rb   rT   rc   rU   rc   rX   rd   r]   rX   r   )rS   rb   rX   r^   rU   rc   rX   r   )rX   DataFrameTableBuilder)re   rf   rg   rh   rp   rj   r   r   r   r{   r   r   r   r-   r%   r#   r   r   _  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 rQ   )r   r8   rT   r   rU   )r<   r   rT   rU   s       r#   rp   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   )rT   SeriesTableBuilderVerboser   rU   SeriesTableBuilderNonVerboser;   s    r#   r   z'SeriesInfoPrinter._create_table_builder  sB     <<4<</,YY ,, 
 0TYY??r%   c                    |y|S )NTr-   r   s     r#   r   z)SeriesInfoPrinter._initialize_show_counts  s    r%   )NN)r   r   rT   rc   rU   rc   rX   rd   )rX   SeriesTableBuilderr   )re   rf   rg   rh   rp   r   r   r-   r%   r#   r   r     sJ    
  $#'		E	E 	E !		E
 
	E
@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]_linesr6   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 rQ   r   r8   r;   s    r#   r8   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   rA   r;   s    r#   rA   z!TableBuilderAbstract.dtype_counts  s     yy%%%r%   c                @    t        | j                  j                        S )z Whether to display memory usage.)r   r   r3   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   rI   r;   s    r#   rI   z(TableBuilderAbstract.memory_usage_string  s     yy,,,r%   c                .    | j                   j                  S rQ   )r   rD   r;   s    r#   rD   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   typer8   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   r8   rN   _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)sortedrA   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rX   r   )rX   r7   rW   rY   r   r_   r[   rX   rd   )re   rf   rg   rh   ri   r   r   rj   r8   r=   rA   r   rI   rD   r   r   r   r-   r%   r#   r   r     s     
N< <       & & , , - - ) )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 rQ   r   r<   r   s     r#   rp   zDataFrameTableBuilder.__init__  s	    #'	r%   c                    g | _         | j                  dk(  r| j                          | j                   S | j                          | j                   S )Nr   )r   r{   _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 rH   N)r   r   r   r   r   r8   re   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#   r8   zDataFrameTableBuilder.data2       yy~~r%   c                .    | j                   j                  S )zDataframe columns.)r   rw   r;   s    r#   rw   zDataFrameTableBuilder.ids7  s     yy}}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                T    | j                   j                  d| j                          yz!Add line containing memory usage.zmemory usage: Nr   r   rI   r;   s    r#   add_memory_usage_linez+DataFrameTableBuilder.add_memory_usage_lineA  "    ^D,D,D+EFGr%   N)r   rl   rX   rd   r   r   )rX   r   r   r]   )re   rf   rg   rh   rp   r   r   r   r   rj   r8   rw   r{   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   z4DataFrameTableBuilderNonVerbose._fill_non_empty_infoK  sL    !!#!!#%%'$$&&( %r%   c                n    | j                   j                  | j                  j                  d             y )NColumnsname)r   r   rw   r   r;   s    r#   r   z8DataFrameTableBuilderNonVerbose.add_columns_summary_lineT  s&    488,,),<=r%   Nr   )re   rf   rg   rh   r   r   r-   r%   r#   r   r   F  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.headersb  r>   r%   c                R    | j                   D cg c]  }t        |       c}S c c}w )z'Widths of header columns (only titles).)r  rz   r<   cols     r#   header_column_widthsz-TableBuilderVerboseMixin.header_column_widthsg  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_widthsz1TableBuilderVerboseMixin._get_gross_column_widthsl  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rQ   )rz   ).0r0   s     r#   	<genexpr>zCTableBuilderVerboseMixin._get_body_column_widths.<locals>.<genexpr>w  s     (qCF(s   )listr  r  r  )r<   strcolsr  s      r#   r  z0TableBuilderVerboseMixin._get_body_column_widthst  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_rowsy  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_counts  r>   r%   c                     yz@Iterator with string representation of body data without counts.Nr-   r;   s    r#   r  z1TableBuilderVerboseMixin._gen_rows_without_counts  r>   r%   c           
         | j                   j                  t        | j                  | j                        D cg c]  \  }}t        ||       c}}      }| j                  j                  |       y c c}}w rQ   )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 rQ   )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)rD   )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rX   zSequence[str]r[   rX   zIterator[Sequence[str]]r   rX   zIterator[str])re   rf   rg   rh   r   ri   rj   r   r  r	  r  r  r  r  r  r#  r)  r-  r/  r2  r-   r%   r#   r   r   X  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 rQ   r   r   r  r  r  r  r  r<   r   r   s      r#   rp   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   z1DataFrameTableBuilderVerbose._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   r{   r;   s    r#   r   z5DataFrameTableBuilderVerbose.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_columnsr2  r;   s    r#   r  z5DataFrameTableBuilderVerbose._gen_rows_without_counts  s<     ""$
 	
 	
s   ;AAAc              #     K   t        | j                         | j                         | j                         | j	                               E d{    y7 wr  )r  rD  rE  r/  r2  r;   s    r#   r  z2DataFrameTableBuilderVerbose._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)	enumeraterw   )r<   i_s      r#   rD  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)rw   r   r  s     r#   rE  z)DataFrameTableBuilderVerbose._gen_columns  s$     88 	$Cs##	$r3  N)r   rl   r   r   rX   rd   r   r4  r5  r6  )re   rf   rg   rh   rp   r   rj   r  r   r  r  rD  rE  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 rQ   r   r   s     r#   rp   zSeriesTableBuilder.__init__  s	     $	r%   c                H    g | _         | j                          | j                   S rQ   )r   r   r;   s    r#   r   zSeriesTableBuilder.get_lines  s    !!#{{r%   c                .    | j                   j                  S )zSeries.r   r;   s    r#   r8   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   rX   rd   r   )rX   r   r   )re   rf   rg   rh   rp   r   rj   r8   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rR  )r   r   r   r   r   r;   s    r#   r   z1SeriesTableBuilderNonVerbose._fill_non_empty_info  s@    !!#!!#$$&&( %r%   Nr   )re   rf   rg   rh   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 rQ   r9  r:  s      r#   rp   z"SeriesTableBuilderVerbose.__init__*  r;  r%   c                   | j                          | j                          | j                          | j                          | j	                          | j                          | j                          | j                  r| j                          yyrR  )	r   r   add_series_name_liner#  r)  r-  r   r   r   r;   s    r#   r   z.SeriesTableBuilderVerbose._fill_non_empty_info5  sp    !!#!!#!!#!$$&&( %r%   c                h    | j                   j                  d| j                  j                          y )NzSeries name: )r   r   r8   r   r;   s    r#   rX  z.SeriesTableBuilderVerbose.add_series_name_lineA  s$    ]499>>*:;<r%   c                (    | j                   rddgS dgS )r  r@  r   rA  r;   s    r#   r  z!SeriesTableBuilderVerbose.headersD  s      $g..yr%   c              #  @   K   | j                         E d{    y7 wr  )r2  r;   s    r#   r  z2SeriesTableBuilderVerbose._gen_rows_without_countsK  s     ##%%%s   c              #  p   K   t        | j                         | j                               E d{    y7 wr  )r  r/  r2  r;   s    r#   r  z/SeriesTableBuilderVerbose._gen_rows_with_countsO  s0     %%'
 	
 	
s   ,646N)r   r   r   r   rX   rd   r   r4  r5  )re   rf   rg   rh   rp   r   rX  rj   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 rQ   r   )r0   s    r#   <lambda>z-_get_dataframe_dtype_counts.<locals>.<lambda>\  s
    aff r%   )r=   value_countsgroupbyr   )dfs    r#   rr   rr   W  s,    
 99!!#++,<=AACCr%   )r!   zstr | Dtyper"   r^   rX   r   )r.   floatr/   r   rX   r   rQ   )r3   r   rX   r9   )rb  r   rX   rZ   )8
__future__r   abcr   r   r   textwrapr   typingr   r   r	   r
   r   pandas._configr   pandas._typingr   r   pandas.io.formatsr   r   pandas.io.formats.printingr   pandasr   r   r   frame_max_cols_subr   r   frame_examples_subframe_see_also_subframe_sub_kwargsseries_examples_subseries_see_also_subseries_sub_kwargsINFO_DOCSTRINGr$   r1   r4   r6   rl   r   r   r   r   r   r   r   r   r   r   r   r   rr   r-   r%   r#   <module>ru     s   "    &
 , 3  @  ? ( QS l B  &&&&&	  9; | 4  &''6	  .0f'4,@ '+#Ps PfIH IX<= <=~0 0$N. Nb(+ (V5E3 5Ep0H0 0Hf>&; >$Z&3 Z&z?$#8:R ?$DK- K@)#5 )/
 24L /
dDr%   