o
    hm                     @  s  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	rPd 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%dKdd Z&dLd$d%Z'	dMdNd)d*Z(G d+d, d,eZ)G d-d. d.e)Z*G d/d0 d0e)Z+G d1d2 d2Z,G d3d4 d4e,Z-G d5d6 d6e,Z.G d7d8 d8eZ/G d9d: d:e/Z0G d;d< d<e0Z1G d=d> d>e/Z2G d?d@ d@e0e2Z3G dAdB dBe/Z4G dCdD dDe4Z5G dEdF dFe4e2Z6dOdIdJZ7dS )P    )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                 C  s   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    r#   j/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/pandas/io/formats/info.py_put_str%  s   r%   numfloatsize_qualifierc                 C  sB   dD ]}| dk r| d| d|   S | d } q| 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 PBr#   )r&   r(   xr#   r#   r$   _sizeof_fmt?  s
   
r0   memory_usagebool | str | None
bool | strc                 C  s   | du rt d} | S )z5Get memory usage based on inputs and display options.Nzdisplay.memory_usager   )r1   r#   r#   r$   _initialize_memory_usage^  s   r4   c                   @  s   e Zd ZU dZded< ded< eed#dd	Zeed$ddZeed%ddZ	eed&ddZ
ed'ddZed'ddZed(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datar3   r1   r    Iterable[Dtype]c                 C     dS )z
        Dtypes.

        Returns
        -------
        dtypes : sequence
            Dtype of each of the DataFrame's columns (or one series column).
        Nr#   selfr#   r#   r$   dtypesx      z_BaseInfo.dtypesMapping[str, int]c                 C  r9   )!Mapping dtype - number of counts.Nr#   r:   r#   r#   r$   dtype_counts  r=   z_BaseInfo.dtype_countsSequence[int]c                 C  r9   )BSequence of non-null counts for all columns or column (if series).Nr#   r:   r#   r#   r$   non_null_counts  r=   z_BaseInfo.non_null_countsr   c                 C  r9   )z
        Memory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        Nr#   r:   r#   r#   r$   memory_usage_bytes  r=   z_BaseInfo.memory_usage_bytesr!   c                 C  s   t | j| j dS )z0Memory usage in a form of human readable string.
)r0   rD   r(   r:   r#   r#   r$   memory_usage_string     z_BaseInfo.memory_usage_stringc                 C  s2   d}| j r| j dkrd| jv s| jj rd}|S )Nr   deepobject+)r1   r@   r7   index_is_memory_usage_qualified)r;   r(   r#   r#   r$   r(     s   


z_BaseInfo.size_qualifierbufWriteBuffer[str] | Nonemax_cols
int | Noneverbosebool | Noneshow_countsNonec                C  s   d S Nr#   )r;   rM   rO   rQ   rS   r#   r#   r$   render  s   	z_BaseInfo.renderNr    r8   r    r>   r    rA   r    r   r    r!   
rM   rN   rO   rP   rQ   rR   rS   rR   r    rT   )__name__
__module____qualname____doc____annotations__propertyr   r<   r@   rC   rD   rF   r(   rV   r#   r#   r#   r$   r5   g  s,   
 

r5   c                   @  s|   e Zd ZdZ	d%d&d	d
Zed'ddZed(ddZed)ddZed*ddZ	ed+ddZ
ed*ddZd,d#d$ZdS )-DataFrameInfoz0
    Class storing dataframe-specific info.
    Nr7   r   r1   r2   r    rT   c                 C     || _ t|| _d S rU   r7   r4   r1   r;   r7   r1   r#   r#   r$   __init__     zDataFrameInfo.__init__r>   c                 C  
   t | jS rU   )_get_dataframe_dtype_countsr7   r:   r#   r#   r$   r@        
zDataFrameInfo.dtype_countsr8   c                 C     | j jS )z
        Dtypes.

        Returns
        -------
        dtypes
            Dtype of each of the DataFrame's columns.
        r7   r<   r:   r#   r#   r$   r<        
zDataFrameInfo.dtypesr   c                 C  rl   )zz
        Column names.

        Returns
        -------
        ids : Index
            DataFrame's column names.
        )r7   columnsr:   r#   r#   r$   ids  rn   zDataFrameInfo.idsr   c                 C  ri   z#Number of columns to be summarized.)lenrp   r:   r#   r#   r$   	col_count     
zDataFrameInfo.col_countrA   c                 C  s
   | j  S )rB   r7   countr:   r#   r#   r$   rC     rt   zDataFrameInfo.non_null_countsc                 C  s   | j dk}| jj d|d S )NrH   TrK   rH   )r1   r7   sumr;   rH   r#   r#   r$   rD     s   
z DataFrameInfo.memory_usage_bytesrM   rN   rO   rP   rQ   rR   rS   c                C  s   t | |||d}|| d S )N)inforO   rQ   rS   )_DataFrameInfoPrinter	to_bufferr;   rM   rO   rQ   rS   printerr#   r#   r$   rV     s   zDataFrameInfo.renderrU   )r7   r   r1   r2   r    rT   rX   rW   r    r   rZ   rY   r\   )r]   r^   r_   r`   rg   rb   r@   r<   rp   rs   rC   rD   rV   r#   r#   r#   r$   rc     s"    rc   c                   @  sl   e Zd ZdZ	d!d"d	d
Zdddddd#ddZed$ddZed%ddZed&ddZ	ed'dd Z
dS )(
SeriesInfoz-
    Class storing series-specific info.
    Nr7   r   r1   r2   r    rT   c                 C  rd   rU   re   rf   r#   r#   r$   rg     rh   zSeriesInfo.__init__)rM   rO   rQ   rS   rM   rN   rO   rP   rQ   rR   rS   c                C  s,   |d urt dt| ||d}|| d S )NzIArgument `max_cols` can only be passed in DataFrame.info, not Series.info)rz   rQ   rS   )
ValueError_SeriesInfoPrinterr|   r}   r#   r#   r$   rV     s   zSeriesInfo.renderrA   c                 C  s   | j  gS rU   ru   r:   r#   r#   r$   rC   $  s   zSeriesInfo.non_null_countsr8   c                 C  s
   | j jgS rU   rm   r:   r#   r#   r$   r<   (  rk   zSeriesInfo.dtypesr>   c                 C  s   ddl m} t|| jS )Nr   )r   )pandas.core.framer   rj   r7   )r;   r   r#   r#   r$   r@   ,  s   zSeriesInfo.dtype_countsr   c                 C  s   | j dk}| jj d|dS )zMemory usage in bytes.

        Returns
        -------
        memory_usage_bytes : int
            Object's total memory usage in bytes.
        rH   Trw   )r1   r7   ry   r#   r#   r$   rD   2  s   
	zSeriesInfo.memory_usage_bytesrU   )r7   r   r1   r2   r    rT   r\   rY   rW   rX   rZ   )r]   r^   r_   r`   rg   rV   rb   rC   r<   r@   rD   r#   r#   r#   r$   r     s"    r   c                   @  s*   e Zd ZdZddddZedd
dZdS )_InfoPrinterAbstractz6
    Class for printing dataframe or series info.
    NrM   rN   r    rT   c                 C  s.   |   }| }|du rtj}t|| dS )z Save dataframe info into buffer.N)_create_table_builder	get_linessysstdoutfmtbuffer_put_lines)r;   rM   table_builderlinesr#   r#   r$   r|   D  s
   z_InfoPrinterAbstract.to_buffer_TableBuilderAbstractc                 C  r9   )z!Create instance of table builder.Nr#   r:   r#   r#   r$   r   L  r=   z*_InfoPrinterAbstract._create_table_builderrU   )rM   rN   r    rT   )r    r   )r]   r^   r_   r`   r|   r   r   r#   r#   r#   r$   r   ?  s
    r   c                   @  sx   e Zd ZdZ			dd ddZed!ddZed"ddZed"ddZed!ddZ	d#ddZ
d$ddZd%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.
    Nrz   rc   rO   rP   rQ   rR   rS   r    rT   c                 C  s0   || _ |j| _|| _| || _| || _d S rU   )rz   r7   rQ   _initialize_max_colsrO   _initialize_show_countsrS   )r;   rz   rO   rQ   rS   r#   r#   r$   rg   a  s
   z_DataFrameInfoPrinter.__init__r   c                 C  s   t dt| jd S )z"Maximum info rows to be displayed.zdisplay.max_info_rows   )r   rr   r7   r:   r#   r#   r$   max_rowsn  rG   z_DataFrameInfoPrinter.max_rowsboolc                 C  s   t | j| jkS )zDCheck if number of columns to be summarized does not exceed maximum.)r   rs   rO   r:   r#   r#   r$   exceeds_info_colss     z'_DataFrameInfoPrinter.exceeds_info_colsc                 C  s   t t| j| jkS )zACheck if number of rows to be summarized does not exceed maximum.)r   rr   r7   r   r:   r#   r#   r$   exceeds_info_rowsx  rG   z'_DataFrameInfoPrinter.exceeds_info_rowsc                 C  rl   rq   rz   rs   r:   r#   r#   r$   rs   }     z_DataFrameInfoPrinter.col_countc                 C  s   |d u rt d| jd S |S )Nzdisplay.max_info_columnsr   )r   rs   )r;   rO   r#   r#   r$   r     s   z*_DataFrameInfoPrinter._initialize_max_colsc                 C  s    |d u rt | j o| j S |S rU   )r   r   r   r;   rS   r#   r#   r$   r     s   z-_DataFrameInfoPrinter._initialize_show_counts_DataFrameTableBuilderc                 C  sN   | j rt| j| jdS | j du rt| jdS | jrt| jdS t| j| jdS )z[
        Create instance of table builder based on verbosity and display settings.
        rz   with_countsFrz   )rQ   _DataFrameTableBuilderVerboserz   rS    _DataFrameTableBuilderNonVerboser   r:   r#   r#   r$   r     s   
z+_DataFrameInfoPrinter._create_table_builder)NNN)
rz   rc   rO   rP   rQ   rR   rS   rR   r    rT   rZ   r    r   )rO   rP   r    r   rS   rR   r    r   )r    r   )r]   r^   r_   r`   rg   rb   r   r   r   rs   r   r   r   r#   r#   r#   r$   r{   Q  s"    

r{   c                   @  s4   e Zd ZdZ		ddd
dZdddZd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.
    Nrz   r   rQ   rR   rS   r    rT   c                 C  s$   || _ |j| _|| _| || _d S rU   )rz   r7   rQ   r   rS   )r;   rz   rQ   rS   r#   r#   r$   rg     s   z_SeriesInfoPrinter.__init___SeriesTableBuilderc                 C  s,   | j s| j du rt| j| jdS t| jdS )zF
        Create instance of table builder based on verbosity.
        Nr   r   )rQ   _SeriesTableBuilderVerboserz   rS   _SeriesTableBuilderNonVerboser:   r#   r#   r$   r     s   z(_SeriesInfoPrinter._create_table_builderr   c                 C  s   |d u rdS |S )NTr#   r   r#   r#   r$   r     s   z*_SeriesInfoPrinter._initialize_show_counts)NN)rz   r   rQ   rR   rS   rR   r    rT   )r    r   r   )r]   r^   r_   r`   rg   r   r   r#   r#   r#   r$   r     s    
r   c                   @  s   e Zd ZU dZded< ded< ed#ddZed$d
dZed%ddZ	ed&ddZ
ed'ddZed(ddZed)ddZd*ddZd*ddZd*d d!Zd"S )+r   z*
    Abstract builder for info table.
    	list[str]_linesr5   rz   r    c                 C  r9   )z-Product in a form of list of lines (strings).Nr#   r:   r#   r#   r$   r     r=   z_TableBuilderAbstract.get_linesr6   c                 C  rl   rU   rz   r7   r:   r#   r#   r$   r7        z_TableBuilderAbstract.datar8   c                 C  rl   )z*Dtypes of each of the DataFrame's columns.)rz   r<   r:   r#   r#   r$   r<     r   z_TableBuilderAbstract.dtypesr>   c                 C  rl   )r?   )rz   r@   r:   r#   r#   r$   r@     r   z"_TableBuilderAbstract.dtype_countsr   c                 C  s   t | jjS )z Whether to display memory usage.)r   rz   r1   r:   r#   r#   r$   display_memory_usage  s   z*_TableBuilderAbstract.display_memory_usager!   c                 C  rl   )z/Memory usage string with proper size qualifier.)rz   rF   r:   r#   r#   r$   rF     r   z)_TableBuilderAbstract.memory_usage_stringrA   c                 C  rl   rU   )rz   rC   r:   r#   r#   r$   rC     r   z%_TableBuilderAbstract.non_null_countsrT   c                 C  s   | j tt| j dS )z>Add line with string representation of dataframe to the table.N)r   appendr!   typer7   r:   r#   r#   r$   add_object_type_line  s   z*_TableBuilderAbstract.add_object_type_linec                 C  s   | j | jj  dS )z,Add line with range of indices to the table.N)r   r   r7   rK   _summaryr:   r#   r#   r$   add_index_range_line     z*_TableBuilderAbstract.add_index_range_linec                 C  s4   dd t | j D }| jdd|  dS )z2Add summary line with dtypes present in dataframe.c                 S  s"   g | ]\}}| d |ddqS )(d)r#   ).0keyvalr#   r#   r$   
<listcomp>  s    z9_TableBuilderAbstract.add_dtypes_line.<locals>.<listcomp>zdtypes: z, N)sortedr@   itemsr   r   join)r;   collected_dtypesr#   r#   r$   add_dtypes_line  s   z%_TableBuilderAbstract.add_dtypes_lineNr    r   )r    r6   rW   rX   r   r[   rY   r    rT   )r]   r^   r_   r`   ra   r   r   rb   r7   r<   r@   r   rF   rC   r   r   r   r#   r#   r#   r$   r     s*   
 

r   c                   @  sp   e Zd ZdZdddZdd	d
ZdddZedddZe	dddZ
e	dddZe	d ddZdddZdS )!r   z
    Abstract builder for dataframe info table.

    Parameters
    ----------
    info : DataFrameInfo.
        Instance of DataFrameInfo.
    rz   rc   r    rT   c                C  
   || _ d S rU   r   r;   rz   r#   r#   r$   rg        
z_DataFrameTableBuilder.__init__r   c                 C  s,   g | _ | jdkr|   | j S |   | j S )Nr   )r   rs   _fill_empty_info_fill_non_empty_infor:   r#   r#   r$   r     s   
z _DataFrameTableBuilder.get_linesc                 C  s0   |    |   | jdt| jj d dS )z;Add lines to the info table, pertaining to empty dataframe.zEmpty rE   N)r   r   r   r   r   r7   r]   r:   r#   r#   r$   r     s    z'_DataFrameTableBuilder._fill_empty_infoc                 C  r9   z?Add lines to the info table, pertaining to non-empty dataframe.Nr#   r:   r#   r#   r$   r     r=   z+_DataFrameTableBuilder._fill_non_empty_infor   c                 C  rl   )z
DataFrame.r   r:   r#   r#   r$   r7   #  r   z_DataFrameTableBuilder.datar   c                 C  rl   )zDataframe columns.)rz   rp   r:   r#   r#   r$   rp   (  r   z_DataFrameTableBuilder.idsr   c                 C  rl   )z-Number of dataframe columns to be summarized.r   r:   r#   r#   r$   rs   -  r   z _DataFrameTableBuilder.col_countc                 C     | j d| j  dS z!Add line containing memory usage.zmemory usage: Nr   r   rF   r:   r#   r#   r$   add_memory_usage_line2  r   z,_DataFrameTableBuilder.add_memory_usage_lineN)rz   rc   r    rT   r   r   )r    r   r   rZ   )r]   r^   r_   r`   rg   r   r   r   r   rb   r7   rp   rs   r   r#   r#   r#   r$   r     s    
	

r   c                   @  s$   e Zd ZdZd	ddZd	ddZdS )
r   z>
    Dataframe info table builder for non-verbose output.
    r    rT   c                 C  s6   |    |   |   |   | jr|   dS dS r   )r   r   add_columns_summary_liner   r   r   r:   r#   r#   r$   r   <  s   z5_DataFrameTableBuilderNonVerbose._fill_non_empty_infoc                 C  s   | j | jjdd d S )NColumnsname)r   r   rp   r   r:   r#   r#   r$   r   E     z9_DataFrameTableBuilderNonVerbose.add_columns_summary_lineNr   )r]   r^   r_   r`   r   r   r#   r#   r#   r$   r   7  s    
	r   c                   @  s   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dZed*ddZ	d*ddZ
d*ddZd+ddZed+ddZed+ddZd,ddZd,dd Zd,d!d"Zd-d$d%Zd-d&d'Zd(S )._TableBuilderVerboseMixinz(
    Mixin for verbose info output.
    z  r!   SPACINGzSequence[Sequence[str]]strrowsrA   gross_column_widthsr   r   r    Sequence[str]c                 C  r9   ).Headers names of the columns in verbose table.Nr#   r:   r#   r#   r$   headersS  r=   z!_TableBuilderVerboseMixin.headersc                 C  s   dd | j D S )z'Widths of header columns (only titles).c                 S  s   g | ]}t |qS r#   rr   r   colr#   r#   r$   r   [  s    zB_TableBuilderVerboseMixin.header_column_widths.<locals>.<listcomp>)r   r:   r#   r#   r$   header_column_widthsX  r   z._TableBuilderVerboseMixin.header_column_widthsc                 C  s   |   }dd t| j|D S )zAGet widths of columns containing both headers and actual content.c                 S  s   g | ]}t | qS r#   max)r   widthsr#   r#   r$   r   `  s    zF_TableBuilderVerboseMixin._get_gross_column_widths.<locals>.<listcomp>)_get_body_column_widthszipr   )r;   body_column_widthsr#   r#   r$   _get_gross_column_widths]  s   
z2_TableBuilderVerboseMixin._get_gross_column_widthsc                 C  s   t t| j }dd |D S )z$Get widths of table content columns.c                 S  s   g | ]}t d d |D qS )c                 s  s    | ]}t |V  qd S rU   r   )r   r/   r#   r#   r$   	<genexpr>h  s    zO_TableBuilderVerboseMixin._get_body_column_widths.<locals>.<listcomp>.<genexpr>r   r   r#   r#   r$   r   h  s    zE_TableBuilderVerboseMixin._get_body_column_widths.<locals>.<listcomp>)listr   r   )r;   strcolsr#   r#   r$   r   e  s   z1_TableBuilderVerboseMixin._get_body_column_widthsIterator[Sequence[str]]c                 C  s   | 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:   r#   r#   r$   	_gen_rowsj  s   z#_TableBuilderVerboseMixin._gen_rowsc                 C  r9   z=Iterator with string representation of body data with counts.Nr#   r:   r#   r#   r$   r   u  r=   z/_TableBuilderVerboseMixin._gen_rows_with_countsc                 C  r9   z@Iterator with string representation of body data without counts.Nr#   r:   r#   r#   r$   r   y  r=   z2_TableBuilderVerboseMixin._gen_rows_without_countsrT   c                 C  0   | j dd t| j| jD }| j| d S )Nc                 S     g | ]	\}}t ||qS r#   r%   )r   header	col_widthr#   r#   r$   r         z=_TableBuilderVerboseMixin.add_header_line.<locals>.<listcomp>)r   r   r   r   r   r   r   )r;   header_liner#   r#   r$   add_header_line}  s   z)_TableBuilderVerboseMixin.add_header_linec                 C  r   )Nc                 S  s   g | ]\}}t d | |qS )-r   )r   header_colwidthgross_colwidthr#   r#   r$   r     s    z@_TableBuilderVerboseMixin.add_separator_line.<locals>.<listcomp>)r   r   r   r   r   r   r   )r;   separator_liner#   r#   r$   add_separator_line  s   z,_TableBuilderVerboseMixin.add_separator_linec                 C  s:   | j D ]}| jdd t|| jD }| j| qd S )Nc                 S  r   r#   r   )r   r   r   r#   r#   r$   r     r   z<_TableBuilderVerboseMixin.add_body_lines.<locals>.<listcomp>)r   r   r   r   r   r   r   )r;   row	body_liner#   r#   r$   add_body_lines  s   

z(_TableBuilderVerboseMixin.add_body_linesIterator[str]c                 c  s    | j D ]}| dV  qdS )z7Iterator with string representation of non-null counts.z	 non-nullN)rC   )r;   rv   r#   r#   r$   _gen_non_null_counts  s   
z._TableBuilderVerboseMixin._gen_non_null_countsc                 c      | j D ]}t|V  qdS )z5Iterator with string representation of column dtypes.N)r<   r
   )r;   dtyper#   r#   r$   _gen_dtypes     
z%_TableBuilderVerboseMixin._gen_dtypesNr    r   rY   r    r   r   r    r   )r]   r^   r_   r`   r   ra   rb   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r#   r#   r$   r   I  s.   
 




	


r   c                   @  sd   e Zd ZdZddd	Zdd
dZedddZdddZdddZ	dddZ
d ddZd ddZdS )!r   z:
    Dataframe info table builder for verbose output.
    rz   rc   r   r   r    rT   c                C  (   || _ || _t|  | _|  | _d S rU   rz   r   r   r   r   r   r   r;   rz   r   r#   r#   r$   rg        z&_DataFrameTableBuilderVerbose.__init__c                 C  N   |    |   |   |   |   |   |   | jr%|   dS dS r   )	r   r   r   r   r   r   r   r   r   r:   r#   r#   r$   r        z2_DataFrameTableBuilderVerbose._fill_non_empty_infor   c                 C  s   | j rg dS g dS )r   ) # ColumnNon-Null Countr   )r  r  r   r   r:   r#   r#   r$   r     s   z%_DataFrameTableBuilderVerbose.headersc                 C  s   | j d| j d d S )NzData columns (total z
 columns):)r   r   rs   r:   r#   r#   r$   r     r   z6_DataFrameTableBuilderVerbose.add_columns_summary_liner   c                 c  s$    t |  |  |  E dH  dS r   )r   _gen_line_numbers_gen_columnsr   r:   r#   r#   r$   r     s   z6_DataFrameTableBuilderVerbose._gen_rows_without_countsc                 c  s*    t |  |  |  |  E dH  dS r   )r   r
  r  r   r   r:   r#   r#   r$   r     s   z3_DataFrameTableBuilderVerbose._gen_rows_with_countsr   c                 c  s&    t | jD ]
\}}d| V  qdS )z6Iterator with string representation of column numbers.r.   N)	enumeraterp   )r;   i_r#   r#   r$   r
    s   z/_DataFrameTableBuilderVerbose._gen_line_numbersc                 c  r   )z4Iterator with string representation of column names.N)rp   r
   )r;   r   r#   r#   r$   r    r   z*_DataFrameTableBuilderVerbose._gen_columnsN)rz   rc   r   r   r    rT   r   r   r   r   )r]   r^   r_   r`   rg   r   rb   r   r   r   r   r
  r  r#   r#   r#   r$   r     s    





	r   c                   @  sJ   e Zd ZdZdddZdd	d
ZedddZdddZe	dddZ
dS )r   z
    Abstract builder for series info table.

    Parameters
    ----------
    info : SeriesInfo.
        Instance of SeriesInfo.
    rz   r   r    rT   c                C  r   rU   r   r   r#   r#   r$   rg     r   z_SeriesTableBuilder.__init__r   c                 C  s   g | _ |   | j S rU   )r   r   r:   r#   r#   r$   r     s   z_SeriesTableBuilder.get_linesr   c                 C  rl   )zSeries.r   r:   r#   r#   r$   r7     r   z_SeriesTableBuilder.datac                 C  r   r   r   r:   r#   r#   r$   r     r   z)_SeriesTableBuilder.add_memory_usage_linec                 C  r9   z<Add lines to the info table, pertaining to non-empty series.Nr#   r:   r#   r#   r$   r     r=   z(_SeriesTableBuilder._fill_non_empty_infoN)rz   r   r    rT   r   )r    r   r   )r]   r^   r_   r`   rg   r   rb   r7   r   r   r   r#   r#   r#   r$   r     s    
	

r   c                   @  s   e Zd ZdZdddZdS )r   z;
    Series info table builder for non-verbose output.
    r    rT   c                 C  s.   |    |   |   | jr|   dS dS r  )r   r   r   r   r   r:   r#   r#   r$   r     s   z2_SeriesTableBuilderNonVerbose._fill_non_empty_infoNr   )r]   r^   r_   r`   r   r#   r#   r#   r$   r     s    r   c                   @  sP   e Zd ZdZddd	Zdd
dZdddZedddZdddZ	dddZ
dS )r   z7
    Series info table builder for verbose output.
    rz   r   r   r   r    rT   c                C  r   rU   r  r  r#   r#   r$   rg     r  z#_SeriesTableBuilderVerbose.__init__c                 C  r  r  )	r   r   add_series_name_liner   r   r   r   r   r   r:   r#   r#   r$   r   &  r  z/_SeriesTableBuilderVerbose._fill_non_empty_infoc                 C  s   | j d| jj  d S )NzSeries name: )r   r   r7   r   r:   r#   r#   r$   r  2  r   z/_SeriesTableBuilderVerbose.add_series_name_liner   c                 C  s   | j rddgS dgS )r   r  r   r	  r:   r#   r#   r$   r   5  s   z"_SeriesTableBuilderVerbose.headersr   c                 c  s    |   E dH  dS r   )r   r:   r#   r#   r$   r   <  s   z3_SeriesTableBuilderVerbose._gen_rows_without_countsc                 c  s    t |  |  E dH  dS r   )r   r   r   r:   r#   r#   r$   r   @  s
   z0_SeriesTableBuilderVerbose._gen_rows_with_countsN)rz   r   r   r   r    rT   r   r   r   )r]   r^   r_   r`   rg   r   r  rb   r   r   r   r#   r#   r#   r$   r     s    



r   dfr>   c                 C  s   | j  dd  S )zK
    Create mapping between datatypes and their number of occurrences.
    c                 S  s   | j S rU   r   )r/   r#   r#   r$   <lambda>M  s    z-_get_dataframe_dtype_counts.<locals>.<lambda>)r<   value_countsgroupbyrx   )r  r#   r#   r$   rj   H  s   rj   )r   r   r   r   r    r!   )r&   r'   r(   r!   r    r!   rU   )r1   r2   r    r3   )r  r   r    r>   )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   r4   r5   rc   r   r   r{   r   r   r   r   r   r   r   r   r   rj   r#   r#   r#   r$   <module>   s    
V	>
3
 	SI<P+83]B 2