HOME


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

���h���
@s�dZddlmZddlmZmZddlmZddlZddl	m
Z
ddlmZddl
Z
ddlZddlmZdd	lmZmZmZmZmZmZmZmZmZmZmZmZmZmZdd
l m!Z!ddl"Z#ddl$m%Z%m&Z&ddl'm(Z(dd
l)m*Z*ddl+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5m6Z6ddl7m8Z8ddl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFddlGmHZHmIZIddlJmKZKddlLmMZMddlNmOZOddlPjQjRZSddlTmUZUddlVmWZWmXZXmYZYmZZZddl[m\Z\ddl]m^Z^ddl_m`Z`ddlambZbmcZcmdZde�r"ddlemfZfmgZgmhZheeeeedfeeeiejfeffZkeeied fZlee6eeiejffZmeeiejeeeiejfee6eeiejfffZnd!Zod�Zpd-ZqGd.d/�d/�ZrGd0d1�d1�ZsGd2d3�d3�ZtGd4d5�d5et�Zuetd6�d7d8�ZvGd9d:�d:�ZwGd;d<�d<ew�Zxd�eeeeeleieejeeeiejfeieieeyeejeeid?�d@dA�ZzGdBdC�dC�Z{GdDdE�dEe{�Z|GdFdG�dGe{�Z}GdHdI�dIe{�Z~GdJdK�dKe{�Zee#j�eeeje�fee�eeeie�ffeeidL�dMdN�Z�ee#j�eKeWe\feydO�dPdQ�Z�d�ee3e0feeeieidS�dTdU�Z�d�ee3e0feideidV�dWdX�Z�d�eyeidedY�dZd[�Z�ee#j�eKe\feeieeid\�d]d^�Z�Gd_d`�d`e~�Z�Gdadb�dbe{�Z�d�ee#j�e^eMfeieyedd�dedf�Z�d�eeieieejeeteeidg�dhdi�Z�d�e#j�eieieeidj�dkdl�Z�d�ee#j�eeifeieieeidm�dndo�Z�eWeydp�dqdr�Z�Gdsd �d �Z�d�ejeyddu�dvdw�Z�eejejeejdx�dydz�Z�d�eeeye�eifeeejejfd|�d}d~�Z�eeieeidd�d�d��Z�dS)�z{
Internal module for formatting output data in csv, html,
and latex files. This module also applies to display formatting.
�)�contextmanager)�
QUOTE_NONE�QUOTE_NONNUMERIC)�tzinfoN)�partial)�StringIO)�get_terminal_size)�IO�
TYPE_CHECKING�Any�Callable�Dict�Iterable�List�Mapping�Optional�Sequence�Tuple�Type�Union�cast)�east_asian_width)�
get_option�
set_option)�lib)�NA)�format_array_from_datetime)�NaT�	Timedelta�	Timestamp�iNaT)�NaTType)�FilePathOrBuffer�Label)�AbstractMethodError)
�is_categorical_dtype�is_complex_dtype�is_datetime64_dtype�is_datetime64tz_dtype�is_extension_array_dtype�is_float�is_float_dtype�
is_integer�is_integer_dtype�is_list_like�is_numeric_dtype�	is_scalar�is_timedelta64_dtype)�isna�notna)�
DatetimeArray)�TimedeltaArray)�PandasObject)�
extract_array)�Index�
MultiIndex�PeriodIndex�ensure_index)�
DatetimeIndex)�TimedeltaIndex)�stringify_path)�adjoin�justify�pprint_thing)�Categorical�	DataFrame�Series.�EngFormattera�	
        Parameters
        ----------
        buf : str, Path or StringIO-like, optional, default None
            Buffer to write to. If None, the output is returned as a string.
        columns : sequence, optional, default None
            The subset of columns to write. Writes all columns by default.
        col_space : %(col_space_type)s, optional
            %(col_space)s.
        header : %(header_type)s, optional
            %(header)s.
        index : bool, optional, default True
            Whether to print index (row) labels.
        na_rep : str, optional, default 'NaN'
            String representation of NAN to use.
        formatters : list, tuple or dict of one-param. functions, optional
            Formatter functions to apply to columns' elements by position or
            name.
            The result of each function must be a unicode string.
            List/tuple must be of length equal to the number of columns.
        float_format : one-parameter function, optional, default None
            Formatter function to apply to columns' elements if they are
            floats. The result of this function must be a unicode string.
        sparsify : bool, optional, default True
            Set to False for a DataFrame with a hierarchical index to print
            every multiindex key at each row.
        index_names : bool, optional, default True
            Prints the names of the indexes.
        justify : str, default None
            How to justify the column labels. If None uses the option from
            the print configuration (controlled by set_option), 'right' out
            of the box. Valid values are

            * left
            * right
            * center
            * justify
            * justify-all
            * start
            * end
            * inherit
            * match-parent
            * initial
            * unset.
        max_rows : int, optional
            Maximum number of rows to display in the console.
        min_rows : int, optional
            The number of rows to display in the console in a truncated repr
            (when number of rows is above `max_rows`).
        max_cols : int, optional
            Maximum number of columns to display in the console.
        show_dimensions : bool, default False
            Display DataFrame dimensions (number of rows by number of columns).
        decimal : str, default '.'
            Character recognized as decimal separator, e.g. ',' in Europe.
    �left�right�centerr@�justify-all�start�end�inherit�match-parent�initial�unsetz�
        Returns
        -------
        str or None
            If buf is None, returns the result as a string. Otherwise returns
            None.
    c@sZeZdZddeeeeeed�dd�Zed�d	d
�Ze	ed�dd�Z
ed�d
d�ZdS)�CategoricalFormatterNT�NaNrB)�categorical�buf�length�na_rep�footercCs8||_|dk	r|ntd�|_||_||_||_t|_dS)N�)rRrrSrUrTrVr�quoting)�selfrRrSrTrUrV�rZ�:/tmp/pip-build-5_djhm0z/pandas/pandas/io/formats/format.py�__init__�szCategoricalFormatter.__init__)�returncCsPd}|jr*|r|d7}|dt|j���7}|jj�}|r@|d7}||7}t|�S)NrWz, zLength: �
)rT�lenrR�_repr_categories_info�str)rYrV�
level_inforZrZr[�_get_footer�s
z CategoricalFormatter._get_footercCst|jj�dd|j|jd�S)N)�float_formatrUrX)�format_arrayrR�_internal_get_valuesrUrX)rYrZrZr[�_get_formatted_values�sz*CategoricalFormatter._get_formatted_valuescCs||j}t|�dkr$|jr |j�SdS|j�}dd�|D�}dj|�}d|dg}|jrn|j�}|rn|j|�tdj|��S)	NrrWcSsg|]}|j��qSrZ)�strip)�.0�irZrZr[�
<listcomp>�sz2CategoricalFormatter.to_string.<locals>.<listcomp>z, �[�]r^)rRr_rVrcrg�join�appendra)rYrR�
fmt_values�values�resultrVrZrZr[�	to_string�s

zCategoricalFormatter.to_string)NTrQT)�__name__�
__module__�__qualname__rr	ra�boolr\rcrrgrsrZrZrZr[rP�s 		rPc
@s�eZdZddeeeeeefeeeeeeeeeeed�dd�Z	dd	�d
d�Z
ed	�dd
�Zee
eefd	�dd�Ze
ed	�dd�Zed	�dd�ZdS)�SeriesFormatterNTrQFrD)�seriesrSrT�header�indexrU�namerd�dtype�max_rows�min_rowscCst||_|dk	r|nt�|_||_||_||_||_||_|
|_||_	|dkrTt
d�}||_|	|_t
�|_|j�dS)Nzdisplay.float_format)ryrrSr|rUrzrTr{r~rrrdr}�_get_adjustment�adj�
_chk_truncate)rYryrSrTrzr{rUr|rdr}r~rrZrZr[r\�szSeriesFormatter.__init__)r]cCs�ddlm}||j}|j}|o,t|j�|k}|j}|r�tt|�}|rPt||�}|dkrl|}|j	d|�}n*|d}||j	d|�|j	|d�f�}||_
nd|_
||_||_dS)Nr)�concat��)
�pandas.core.reshape.concatr�rr~r_ryr�int�min�iloc�
tr_row_num�	tr_series�
truncate_v)rYr�rr~r�ry�row_numrZrZr[r�s&

"zSeriesFormatter._chk_truncatecCs@|jj}d}t|jjdd�dk	rLt|jjtttf�s8t�|d|jjj	��7}|jdk	r�|dk	r�|rj|d7}t
|dd	�}|d
|��7}|jdks�|jdkr�|jr�|r�|d7}|d
t
|j���7}|jdk	o�|jdk	�rt|jjdd�}|�r|r�|d7}|dt
|���7}t|jj��r8|jjj�}|�r0|d7}||7}t|�S)NrW�freqzFreq: Fz, �	�
r^)�escape_charszName: T�truncatezLength: r|zdtype: )r�r�r^)ryr|�getattrr{�
isinstancer<r:r=�AssertionErrorZfreqstrrArTr�r_r}r�r%�_valuesr`ra)rYr|rVZseries_nameZ
dtype_namerbrZrZr[rc$s6zSeriesFormatter._get_footercCsR|jj}t|t�r4tdd�|jD��}|jdd�}n|jdk	}|jdd�}||fS)Ncss|]
}|VqdS)NrZ)rir|rZrZr[�	<genexpr>Osz7SeriesFormatter._get_formatted_index.<locals>.<genexpr>T)�names)r|)r�r{r�r9�anyr��formatr|)rYr{�have_header�	fmt_indexrZrZr[�_get_formatted_indexKs

z$SeriesFormatter._get_formatted_indexcCst|jjd|j|jd�S)N)rdrU)rer�r�rdrU)rYrZrZr[rgVs
z%SeriesFormatter._get_formatted_valuescCs,|j}|j�}t|�dkr2t|j�j�d|�d�S|j�\}}|j�}|jr�d}|j	}t
t|�}|jj||d�}|dkr�d}	nd}	|jj
|	g|dd	�d}	|j|||	�|j|dd
�|jr�|jjd|dd�|g��}
n|jjd|�}
|jo�|�r|dd|
}
|�r|
d|7}
td
j|
��S)
Nrz([], �)r��z...z..rH)�moderWr^)r�)r�rcr_�typeryrtr�rgr�r�rr�r�r@�insertr{r?rzrarn)rYryrVr�r�rp�
n_header_rowsr��width�dot_strrrrZrZr[rs^s2
zSeriesFormatter.to_string)
NTTTrQFNTNN)rtrurvrr	rarrwr�r\r�rcrrr�rgrsrZrZrZr[rx�s@'rxc@sNeZdZdd�Zeed�dd�Zdeeeeed�dd	�Z	eed
�dd�Z
d
S)�TextAdjustmentcCstd�|_dS)Nzdisplay.encoding)r�encoding)rYrZrZr[r\�szTextAdjustment.__init__)�textr]cCst|�S)N)r_)rYr�rZrZr[r_�szTextAdjustment.lenrG)�texts�max_lenr�r]cCst|||d�S)N)r�)r@)rYr�r�r�rZrZr[r@�szTextAdjustment.justify)�spacer]cOst|f|�|j|jd�|��S)N)ZstrlenZjustfunc)r?r_r@)rYr��lists�kwargsrZrZr[r?�szTextAdjustment.adjoinN)rG)rtrurvr\rar�r_rrr@r?rZrZrZr[r��sr�csJeZdZ�fdd�Zeed�dd�Zd
eeeeeed�dd	�Z	�Z
S)�EastAsianTextAdjustmentcs6t�j�td�rd|_nd|_dddddd�|_dS)Nz!display.unicode.ambiguous_as_wider�r�)ZNa�N�W�F�H)�superr\r�ambiguous_width�_EAW_MAP)rY)�	__class__rZr[r\�s

z EastAsianTextAdjustment.__init__)r�r]cs(t|t�st|�St�fdd�|D��S)zN
        Calculate display width considering unicode East Asian Width
        c3s"|]}�jjt|��j�VqdS)N)r��getrr�)ri�c)rYrZr[r��sz.EastAsianTextAdjustment.len.<locals>.<genexpr>)r�rar_�sum)rYr�rZ)rYr[r_�s
zEastAsianTextAdjustment.lenrG)r�r�r�r]csX��fdd��|dkr(�fdd�|D�S|dkrB�fdd�|D�S�fdd�|D�SdS)	Ncs��j|�t|�S)N)r_)�t)r�rYrZr[�_get_pad�sz1EastAsianTextAdjustment.justify.<locals>._get_padrFcsg|]}|j�|���qSrZ)�ljust)ri�x)r�rZr[rk�sz3EastAsianTextAdjustment.justify.<locals>.<listcomp>rHcsg|]}|j�|���qSrZ)rH)rir�)r�rZr[rk�scsg|]}|j�|���qSrZ)�rjust)rir�)r�rZr[rk�srZ)rYr�r�r�rZ)r�r�rYr[r@�szEastAsianTextAdjustment.justify)rG)rtrurvr\rar�r_rrr@�
__classcell__rZrZ)r�r[r��sr�)r]cCstd�}|rt�St�SdS)Nz display.unicode.east_asian_width)rr�r�)Zuse_east_asian_widthrZrZr[r��sr�c@s�eZdZUeeefee	e
eed�dd��Z
eeefeed�dd�Zedeeeeed�d	d
��Zeedd�dd
�Zdeeeeeeed�dd�ZdS)�TableFormatter)r]cCs|jdkp|jdko|jS)NTr�)�show_dimensions�is_truncated)rYrZrZr[�should_show_dimensions�s
z%TableFormatter.should_show_dimensions)rjr]cCs`t|jttf�r2t|�r,tt|�}|j|SdSn*t|�rN||jkrN|j|}|jj|d�SdS)N)	r��
formatters�list�tupler,rr��columnsr�)rYrjrZrZr[�_get_formatter�s


zTableFormatter._get_formatterN)rSr�c	cs�|dk	rt|�}nt�}|dkr&d}nt|t�s8td��t|d�rJ|Vn6t|t�rxt|d|dd��}|VWdQRXntd��dS)	z�
        Context manager to open, yield and close buffer for filenames or Path-like
        objects, otherwise yield buf unchanged.
        Nzutf-8z1buf is not a file name and encoding is specified.�write�wrW)r��newlinez1buf is not a file name and it has no write method)r>rr�ra�
ValueError�hasattr�open�	TypeError)rYrSr��frZrZr[�
get_buffer�s



zTableFormatter.get_buffer)rSr]cCst|��dS)z;
        Write the result of serialization to buf.
        N)r$)rYrSrZrZr[�write_result�szTableFormatter.write_result)rSr�r]c
Cs:|j||d��"}|j|d�|dkr,|j�SdSQRXdS)zY
        Perform serialization. Write to buf or return as string if buf is None.
        )r�)rSN)r�r��getvalue)rYrSr�r�rZrZr[�
get_result�s
zTableFormatter.get_result)N)NN)rtrurvrrwrar�r��FormattersTyper�r8r��propertyr�r�rrr�rr"r�r	r�r�rZrZrZr[r��s
 r�c@s,eZdZUdZerendZeee7Zed1dee	e
eeee
e	e
fe
e
eeee
eeee
e
eeeeeeeeee
e
fe
ee
e
e
e
d	�d
d�Zdd�d
d�Zeee
d�dd�Zee
dd�dd�Ze
d�dd�Zd2eee
ee
ee
d�dd�Zd3eee
ee
e
ee
e
ee
e
ee
ee
ee
d�
dd�Zeee
d�dd�Zd4eee
ee
eee
eefe
eeee
d�d d!�Zdeee
d"�d#d$�Zee
d�d%d&��Z ee
d�d'd(��Z!ee
d�d)d*��Z"ee
d�d+d,��Z#dee
d"�d-d.�Z$ee
d�d/d0�Z%dS)5�DataFrameFormatterz�
    Render a DataFrame

    self.to_string() : console-friendly tabular output
    self.to_html()   : html table
    self.to_latex()   : LaTeX tabular environment table

    rWNTrQF�.rC)�framer��	col_spacerzr{rUr�r@rd�sparsify�index_names�
line_widthr~r�max_colsr��decimal�table_id�render_links�	bold_rows�escapecs||_||_|
dkrtd�}
|
|_|	|_|dkr8i|_nDt|j�t|�ksTt|t	�r\||_n t
dt|��dt|j��d���||_||_�dkr�i|_
n�t�ttf�r�d�i|_
|j
j�fdd�|jjD��n�t�t��rx2�j�D]&}||jjko�|dkr�t
d|����q�W�|_
nHt|j�t��k�rLt
d	t���dt|j��d���t	t|jj���|_
||_||_||_|
|_||_||_t|
�p�t|j�t|j��|_||_||_||_|dk�r�td
�|_n||_||_ ||_!|dk	�rt"|�|_|j|j|_n|j|_|j#�t$�|_%dS)Nzdisplay.multi_sparsezFormatters length(z+) should match DataFrame number of columns(r�rWcsi|]
}�|�qSrZrZ)ri�column)r�rZr[�
<dictcomp>Msz/DataFrameFormatter.__init__.<locals>.<dictcomp>z,Col_space is defined for an unknown column: zCol_space length(zdisplay.colheader_justify)&r��show_index_namesrr�rdr�r_r�r��dictr�rUr�r�r�ra�updater�keys�ziprzr{r�r~rr�r�Zmax_rows_displayedr�r�r�r@r�r�r;r�r�r�)rYr�r�r�rzr{rUr�r@rdr�r�r�r~rr�r�r�r�r�r�r�r�rZ)r�r[r\sd
 


zDataFrameFormatter.__init__)r]cCs�ddlm}|j}|j}||dks,|dkr�t�\}}||_||_|jdkr�d}d}|jr^d}tt	|j
�|_
|j
|||}	|j|	}
|
|_|dkr�t|j
j�|kr�|}|dkr�t|j
�|kr�|}t|d�s�|r�t|j
�|kr�|jr�t|j|�}||_t|d��s
||_|j}|j}
|�o(t|j�|k}|
�o<t|j
�|
k}
|j
}|�rtt|�}|dk�rjt|j�}n�|dk�r�tt|�}|jdd�d|�f}|}nr|d}||jdd�d|�f|jdd�|d�ffdd	�}t|jttf��r|j}|d|�||d��|_||_|
�r�tt|
�}
|
dk�rH|}|jd|�dd�f}n:|
d}||jd|�dd�f|j|d�dd�ff�}||_nd|_||_||_|
|_t	|j�p�|j�|_dS)
zc
        Checks whether the frame should be truncated. If so, slices
        the frame up.
        r)r�r�r��max_rows_adj�max_cols_adjNr�)�axis)r�r�r�r~rr��hr�rrwrzr�r_r�r�r�rr�r�r�r�r�r�r�r��
tr_col_numr��tr_frame�
truncate_hr�r�)rYr�r�r~r�r�Zdot_rowZ
prompt_rowZshow_dimension_rowsZ
n_add_rowsr�r�r�r�r��col_numZtruncate_fmtr�rZrZr[r�ys|







4


2z DataFrameFormatter._chk_truncatecs�dd��jj�D�}�j}�j|�}t�j�r��jr�g}xDt|�D]8\}}�j|�}t|�j	|j
|d��jd�}|j|�qFW�n4t�j�r�t
tt�j��_t�j�t�j�kr�tdt�j��dt�j��d���dd	��jD�}n
�j|�}�j�rx|D]}	|	jd
��qWg}x�t|�D]�\}}||}
t|j
|d�f�fdd�|
D���}�j|�}t|�j	|�jd�}tt�fd
d�|D��|�}�jj	|
|�j	d�}
|j|
|��q$W|}
�j�r�|
jd|��j}�j}|�r�j}|
j�jddgt|��|�r�t|�t|�}�j}t
t|�}x�t|
�D]�\}}�jj|
||�}d}|�rh||dk}|dk�sx|�r~d}nd}|dk�r�d}n|�r�d}d}nd}�jj	|g||d�d}|
|j|||��q6W|
S)zP
        Render a DataFrame to a list of columns (as lists of strings).
        cSsi|]\}}tt|�|�qSrZ)rr�)ri�k�vrZrZr[r��sz6DataFrameFormatter._to_str_columns.<locals>.<dictcomp>r)�minimumr�zWriting z cols but got z aliasescSsg|]
}|g�qSrZrZ)ri�labelrZrZr[rk�sz6DataFrameFormatter._to_str_columns.<locals>.<listcomp>rWc3s|]}�jj|�VqdS)N)r�r_)rir�)rYrZr[r�sz5DataFrameFormatter._to_str_columns.<locals>.<genexpr>c3s|]}�jj|�VqdS)N)r�r_)rir�)rYrZr[r�s)r�r�z ...Fr�z...z..rF�rG)r��itemsr�r�r.rz�	enumerate�_format_col�_make_fixed_widthr@r�r�rorrrar_r�r��_get_formatted_column_labels�show_row_idx_names�maxr{r�r�r�r�r�r�)rYr�r�Z	str_indexZstringifiedrjr�rp�str_columnsr�ZcheaderZheader_colwidthr��strcolsr�r�r�r�r��ix�colZcwidthZ
is_dot_colZmy_strZdot_moder�rZ)rYr[�_to_str_columns�sx


 

"


z"DataFrameFormatter._to_str_columns)rSr]cs�ddlm�|j}t|j�dks.t|j�dkr`dt|j�j�dt|j��dt|j���}|}�nD|j	�}|j
dkr�|jjd|��}�nt
|jt�s�|jdkr�|j|�}n�|jjd|��jd�}�|�jj�j�}||j}|d}	��fd	d
�|D��}
t|
�}d}xb|	dk�rh|dk�rh|d7}tt|d��}
|
j|
}|
|}|	|d8}	|
j|�}
t|
�}�qW||j}t|d�}||_|j�|j	�}|jjd|��}|j|�|j�r�|jd
t|��dt|j��d��dS)zJ
        Render a DataFrame to a console-friendly tabular output.
        r)rDzEmpty z

Columns: z
Index: Nr�r^csg|]}�|�jt�j��qSrZ)�applyr_r�)riZele)rDrZr[rkQsz3DataFrameFormatter.write_result.<locals>.<listcomp>g@r�z

[z rows x z	 columns])r�)r�)r�)�pandasrDr�r_r�r{r�rtrArr�r�r?r�r�r��_join_multiline�splitrar�r��roundZdropr�r��
writelinesr�r�)rYrSr�Z	info_liner�r�linesr�ZdifZadj_difZcol_lensZn_cols�counterZmidZmid_ixZcol_lenr�rZ)rDr[r�1sD*






zDataFrameFormatter.write_resultcsR�j}d}t|�}�jrF|jd�}|tj�fdd�|D��j�|8}�fdd�|D�}|dk	sdt�t||�}t	|�}�j
r�tt�j
��_
�j
d}	n
t	�j�}	g}
d}x�t|�D]�\}}
|||
�}�jr�|jd|�|dk�r(|
t	|�ko�||dk�r|jdgdg|	d�n|jdg|	�|
j�jj|f|���|
}q�Wd	j|
�S)
Nr�rcsg|]}�jj|��qSrZ)r�r_)rir�)rYrZr[rkssz6DataFrameFormatter._join_multiline.<locals>.<listcomp>cs8g|]0}t|�dkr0tj�fdd�|D��j�nd�qS)rcsg|]}�jj|��qSrZ)r�r_)rir�)rYrZr[rkvszADataFrameFormatter._join_multiline.<locals>.<listcomp>.<listcomp>)r_�np�arrayr�)rir)rYrZr[rkvsz \z  � z

)r�r�r{�poprr
r�r��_binifyr_r�rr�r�r�r�r�ror�r?rn)rY�argsZlwidth�adjoin_widthr�idxZ
col_widthsZcol_binsZnbinsZnrowsZstr_lst�strjZed�rowrZ)rYr[rms8
$



z"DataFrameFormatter._join_multiline)rSr�r]cCs|j||d�S)N)rSr�)r�)rYrSr�rZrZr[rs�szDataFrameFormatter.to_string)
rS�
column_format�	longtabler��multicolumn�multicolumn_format�multirow�captionr�r]c

Cs.ddlm}
|
||||||||	d�j||d�S)zU
        Render a DataFrame to a LaTeX tabular/longtable environment output.
        r)�LatexFormatter)rrrrrrr�)rSr�)Zpandas.io.formats.latexrr�)rYrSrrr�rrrrr�rrZrZr[�to_latex�szDataFrameFormatter.to_latex)rjr]cCsH|j}|j|�}t|jdd�|fj||j|j|jj|j	|�|j
d�S)N)rdrUr�r�)r�r�rer�r�rdrUr�r�r�r�)rYrjr��	formatterrZrZr[r��s
zDataFrameFormatter._format_col)rSr��classes�notebook�borderr]c	Cs4ddlm}m}|r|n|}||||d�j||d�S)a(
        Render a DataFrame to a html table.

        Parameters
        ----------
        classes : str or list-like
            classes to include in the `class` attribute of the opening
            ``<table>`` tag, in addition to the default "dataframe".
        notebook : {True, False}, optional, default False
            Whether the generated HTML is for IPython Notebook.
        border : int
            A ``border=border`` attribute is included in the opening
            ``<table>`` tag. Default ``pd.options.display.html.border``.
        r)�
HTMLFormatter�NotebookFormatter)rr!)rSr�)Zpandas.io.formats.htmlr"r#r�)	rYrSr�rr r!r"r#ZKlassrZrZr[�to_html�szDataFrameFormatter.to_html)r�r]csddlm}|j}t|t�r�|jddd�}tt|��}�jj	j
}tdd�|jD���t
t|tt|�������fdd��tt�fd	d
�|D���}�jr�t|�r�||�}dd
�t|�D�}nB|j�}�jj	}t
t|tt|������fdd
�tt||��D�}|S)
Nr)�	_sparsifyF)r�r?css|]}|jVqdS)N)Zis_floating)ri�lrZrZr[r��szBDataFrameFormatter._get_formatted_column_labels.<locals>.<genexpr>cs$|�jkr �|r �r d|S|S)Nr)r�)r��y)�need_leadsp�restrict_formattingrYrZr[�space_format�s

zEDataFrameFormatter._get_formatted_column_labels.<locals>.space_formatcs g|]���fdd��D��qS)csg|]}��|��qSrZrZ)rir')r*r�rZr[rk�szNDataFrameFormatter._get_formatted_column_labels.<locals>.<listcomp>.<listcomp>rZ)ri)r*)r�r[rk�szCDataFrameFormatter._get_formatted_column_labels.<locals>.<listcomp>cSsg|]}t|��qSrZ)r�)rir�rZrZr[rk�scs6g|].\}\}}�j|�r,�|r,d|n|g�qS)r)r�)rirjrr�)r(rYrZr[rks)Zpandas.core.indexes.multir%r�r�r9r�r�r�r��dtypesr�r��levelsr��mapr/r�r_r�)rYr�r%r�Zfmt_columnsr+r�rZ)r(r)rYr*r[r��s(

	z/DataFrameFormatter._get_formatted_column_labelscCst|jj�S)N)�
_has_namesr�r{)rYrZrZr[�has_index_names	sz"DataFrameFormatter.has_index_namescCst|jj�S)N)r.r�r�)rYrZrZr[�has_column_names
sz#DataFrameFormatter.has_column_namescCst|j|j|jf�S)N)�allr/r{r�)rYrZrZr[r�sz%DataFrameFormatter.show_row_idx_namescCst|j|j|jf�S)N)r1r0r�rz)rYrZrZr[�show_col_idx_namessz%DataFrameFormatter.show_col_idx_namescs�dd��jj�D��|j}|j}�jd�}t|t�rL|j�jd�j	|d�}n|j�j	|d�g}��fdd�|D�}�j
jd
|��jd
�}�j
r�dd��j�D�}ndg|j}�jr�||S|SdS)NcSsi|]\}}tt|�|�qSrZ)rr�)rir�r�rZrZr[r�sz;DataFrameFormatter._get_formatted_index.<locals>.<dictcomp>�	__index__F)r�r?r�r)r|rc	s.g|]&}ttt|�d�jdd��jd���qS)rFrWr)r@r�r�)r�r�r�r�r�)rir�)r�rYrZr[rk,sz;DataFrameFormatter._get_formatted_index.<locals>.<listcomp>r�r^cSsg|]}t|��qSrZ)ra)rir�rZrZr[rk8srW)r�)r�r�r{r�r�r�r9r�r�r�r�r?rr2�_get_column_name_listZnlevelsrz)rYr�r{r��fmtr�ZadjoinedZ
col_headerrZ)r�rYr[r�s(


z'DataFrameFormatter._get_formatted_indexcCsLg}|jj}t|t�r.|jdd�|jD��n|j|jdkr@dn|j�|S)Ncss|]}|dkrdn|VqdS)NrWrZ)rir|rZrZr[r�Esz;DataFrameFormatter._get_column_name_list.<locals>.<genexpr>rW)r�r�r�r9�extendr�ror|)rYr�r�rZrZr[r4As
z(DataFrameFormatter._get_column_name_list)NNTTrQNNNNTNNNNFr�NFFT)NN)	NNFNFNFNN)NNNFN)&rtrurv�__doc__�common_docstring�return_docstring�ColspaceTyper�rrra�ColspaceArgTyperrwr��FloatFormatTyper�r\r�rrr	r�rr"rsrr�rr$r�r�r/r0r�r2r�r4rZrZrZr[r�sv
|F][<)0*)(r�rQr�)rqrrdrU�digitsr�r@r��
leading_spacerXr]c
Cs�t|j�rt}
n^t|j�r t}
nNt|j�r0t}
n>t|j�r@t}
n.t	|j�sTt
|j�rZt}
nt|j�rjt
}
nt}
|dkr~td�}|dkr�td�}|dkr�td�}|
||||||||||	d�
}|j�S)aV
    Format an array for printing.

    Parameters
    ----------
    values
    formatter
    float_format
    na_rep
    digits
    space
    justify
    decimal
    leading_space : bool, optional
        Whether the array should be formatted with a leading space.
        When an array as a column of a Series or DataFrame, we do want
        the leading space to pad between columns.

        When formatting an Index subclass
        (e.g. IntervalIndex._format_native_types), we don't want the
        leading space since it should be left-aligned.

    Returns
    -------
    List[str]
    Nzdisplay.column_spacezdisplay.float_formatzdisplay.precision)	r=rUrdrr�r@r�r>rX)r'r}�Datetime64Formatterr(�Datetime64TZFormatterr1�Timedelta64Formatterr)�ExtensionArrayFormatterr+r&�FloatArrayFormatterr-�IntArrayFormatter�GenericArrayFormatterrr�)rqrrdrUr=r�r@r�r>rXZ	fmt_klassZfmt_objrZrZr[reOs>'




rec
@sleZdZdeeeeeeeefee	eeeee
ee
d�d	d
�Zeed�dd
�Z
eed�dd�ZdS)rE�NrQ�rGr�T)rqr=rrUr�rdr@r�rX�fixed_widthr>cCsF||_||_||_||_||_||_||_||_|	|_|
|_	||_
dS)N)rqr=rUr�rrdr@r�rXrHr>)rYrqr=rrUr�rdr@r�rXrHr>rZrZr[r\�szGenericArrayFormatter.__init__)r]cCs|j�}t||j�S)N)�_format_stringsr�r@)rYrprZrZr[r��sz GenericArrayFormatter.get_resultcsR�jdkr0td�}|dkr6td���fdd�}n�j}�jdk	rH�j�n"�jdk	oZ�jtk}ttd|d����fd	d
�}t�jdd�}t	j
|t�tj
t|�ttd
t|j���d�@}�j}|dkr�|j�}g}x~t|�D]r\}}	||o�|�r|jd||	����q�||�r |j||	��q�|dk�r0d}
nd}
|j|
j||	�d��q�W|S)Nzdisplay.float_formatzdisplay.precisioncs|d�d�d��S)Nz .�d�grZ)r�)�	precisionrZr[�<lambda>�sz7GenericArrayFormatter._format_strings.<locals>.<lambda>r�r�r^)r��
quote_stringscs��jdk	rpt|�rpt|�rpy6|dkr(dS|tkr8tt�S|tksJtj|�rNdSWntt	fk
rhYnX�jSt
|t�r�t|�St�|��SdS)N�Noner)rUr0r2rrarrZisnatr�r�r�r6)r�)rrYrZr[�_format�s
z6GenericArrayFormatter._format_strings.<locals>._formatT)�
extract_numpyr�)r�rFz{v}z {v})r�)r�r�r^)rdrrrXrrrAr7rqrZ	map_inferr*rr1r3r��ranger_�shaper>r�r�ror�)rYrdrNrP�valsZ
is_float_typer>rprjr��tplrZ)rrLrYr[rI�s>


$

z%GenericArrayFormatter._format_strings)
rFNrQrGNrGr�NTN)rtrurvrr�rrrarr<rwr\rr�rIrZrZrZr[rE�s<rEcsfeZdZdZ�fdd�Zd
eeeeee	fe
d�dd�Zej
d�d	d
�Zeed�dd�Z�ZS)rCz

    csDt�j||�|jdk	r@|jdkr@d|_t|j�r@|j|_d|_dS)NF)r�r\rdrrH�callable)rYrr�)r�rZr[r\s
zFloatArrayFormatter.__init__N)rd�	thresholdr]csl�dkr�j��r"��fdd��n�fdd���jdkrH��fdd��n���dkrX�S���fdd	�}|S)
z;Returns a function to be applied on each value to format itNcst|�r�|d�S�jS)N)�value)r3rU)r�)rdrYrZr[�base_formatter%sz<FloatArrayFormatter._value_formatter.<locals>.base_formattercst|�rt|�S�jS)N)r3rarU)r�)rYrZr[rY*sr�cs�|�jd�jd�S)Nr�r�)�replacer�)r�)rYrYrZr[�decimal_formatter/sz?FloatArrayFormatter._value_formatter.<locals>.decimal_formattercs0t|�r&t|��kr�|�S�d�Sn�jSdS)Ng)r3�absrU)rX)r[rYrWrZr[r8s

z7FloatArrayFormatter._value_formatter.<locals>.formatter)rdr�)rYrdrWrrZ)rYr[rdrYrWr[�_value_formatters
	z$FloatArrayFormatter._value_formatter)r]c	s:�jdk	r$tj�fdd��jD��S�jr4td��nd���fdd�}�jdkrp�jrhtdj�j	d�}q|�j}n�fd	d
�}||�}�js�|St
|�dkr�tdd
�|D��}|�j	dk}nd}tjdd��:tj
�j�}|dkj�}|d�j	k|dk@j�}WdQRX|�s|�r6|�r6tdj�j	d�}||�}|S)z�
        Returns the float values converted into strings using
        the parameters given at initialisation, as a numpy array
        Ncsg|]}�j|��qSrZ)r)rir�)rYrZr[rkIsz;FloatArrayFormatter.get_result_as_array.<locals>.<listcomp>zdisplay.chop_thresholdcs��j|����jdkr"d�j}n�j}�j}t|�}t|�}tj|dd�}|||<|j�}tj�fdd�|j�|D��|j	|<�j
r�|r�t|�j|�}nt
|�j|�}tj|dd�S|S)NrFr�object)r}csg|]}�|��qSrZrZ)ri�val)rrZr[rkcszWFloatArrayFormatter.get_result_as_array.<locals>.format_values_with.<locals>.<listcomp>)r]r@rUrqr&r2rr
�ravelZflatrH�_trim_zeros_complexr��_trim_zeros_float�asarray)rdrUrqZ
is_complex�maskZimaskrr)rYrW)rr[�format_values_withQs$

"zCFloatArrayFormatter.get_result_as_array.<locals>.format_values_withz{value: .{digits:d}f})r=cs
�j|S)N)rd)rX)rYrZr[rMzsz9FloatArrayFormatter.get_result_as_array.<locals>.<lambda>rcss|]}t|�VqdS)N)r_)rir�rZrZr[r��sz:FloatArrayFormatter.get_result_as_array.<locals>.<genexpr>�F�ignore)�invalidg��.A�
z{value: .{digits:d}e})rrr
rqrHrrdrr�r=r_r��errstater\r�)	rYrerdZformatted_values�maxlenZtoo_longZabs_valsZhas_large_valuesZhas_small_valuesrZ)rYrWr[�get_result_as_arrayCs6

!
&z'FloatArrayFormatter.get_result_as_arraycs*�jdk	r�fdd��jD�St�j��S)Ncsg|]}�j|��qSrZ)r)rir�)rYrZr[rk�sz7FloatArrayFormatter._format_strings.<locals>.<listcomp>)rrqr�rl)rYrZ)rYr[rI�s
z#FloatArrayFormatter._format_strings)NN)rtrurvr7r\rr<r�floatr�rr]r�ndarrayrlrrarIr�rZrZ)r�r[rCs,XrCc@seZdZeed�dd�ZdS)rD)r]cs&|jpdd���fdd�|jD�}|S)NcSs|d�S)Nz drZ)r�rZrZr[rM�sz3IntArrayFormatter._format_strings.<locals>.<lambda>csg|]}�|��qSrZrZ)rir�)rrZr[rk�sz5IntArrayFormatter._format_strings.<locals>.<listcomp>)rrq)rYrprZ)rr[rI�sz!IntArrayFormatter._format_stringsN)rtrurvrrarIrZrZrZr[rD�srDcsHeZdZd
eejdeefedd��fdd�
Z	e
ed�dd	�Z�ZS)r?rNrD)rq�nat_rep�date_formatcs t�j|f|�||_||_dS)N)r�r\rorp)rYrqrorpr�)r�rZr[r\�szDatetime64Formatter.__init__)r]csl�j}t|t�st|�}�jdk	r>t�j�r>�fdd�|D�St|jj�t|�j	��j
d�j|j�}|j
�S)z( we by definition have DO NOT have a TZ Ncsg|]}�j|��qSrZ)r)rir�)rYrZr[rk�sz7Datetime64Formatter._format_strings.<locals>.<listcomp>)r�rU)rqr�r<rrVr�asi8r`�"_get_format_datetime64_from_valuesrproZreshaperS�tolist)rYrqrprZ)rYr[rI�s


z#Datetime64Formatter._format_strings)rN)
rtrurvrrrnr<r4rar\rrIr�rZrZ)r�r[r?�s&r?c@seZdZeed�dd�ZdS)rB)r]c
Cs`t|jdd�}|jdd�}t|j�r.|j�}n
tj|�}t|||j	|j
|j|j|j
|jd�}|S)NT)rQ)Zboxed)rdrUr=r�r@r>)r7rq�
_formatterr%r}rfrrcrerdrUr=r�r@r>)rYrqrr
rprZrZr[rI�s



z'ExtensionArrayFormatter._format_stringsN)rtrurvrrarIrZrZrZr[rB�srB)�percentilesr]cCsXtj|�}tjdd��8t|�sBtj|dk�sBtj|dk�rJtd��WdQRXd|}tj|jt�|�}tj|�r�|jt�jt	�}dd	�|D�Stj
|�}|ddkr�|dnd}|d
dkr�d|dnd}tjtjtj
tj|||d
����jt�}td|�}tj|td�}||jt�jt	�||<||j|�jt	�||<dd	�|D�S)a
    Outputs rounded and formatted percentiles.

    Parameters
    ----------
    percentiles : list-like, containing floats from interval [0,1]

    Returns
    -------
    formatted : list of strings

    Notes
    -----
    Rounding precision is chosen so that: (1) if any two elements of
    ``percentiles`` differ, they remain different after rounding
    (2) no entry is *rounded* to 0% or 100%.
    Any non-integer is always rounded to at least 1 decimal place.

    Examples
    --------
    Keeps all entries different after rounding:

    >>> format_percentiles([0.01999, 0.02001, 0.5, 0.666666, 0.9999])
    ['1.999%', '2.001%', '50%', '66.667%', '99.99%']

    No element is rounded to 0% or 100% (unless already equal to it).
    Duplicates are allowed:

    >>> format_percentiles([0, 0.5, 0.02001, 0.5, 0.666666, 0.9999])
    ['0%', '50%', '2.0%', '50%', '66.67%', '99.99%']
    rg)rhrr�z/percentiles should all be in the interval [0,1]N�dcSsg|]}|d�qS)�%rZ)rirjrZrZr[rksz&format_percentiles.<locals>.<listcomp>)�to_begin�to_end)r}cSsg|]}|d�qS)rwrZ)rirjrZrZr[rk#s���rz)rrcrjr/r1r��isclose�astyper�ra�unique�floor�log10r�Zediff1dr�Z
empty_liker^r)ruZint_idx�outZunique_pctsrxry�precrZrZr[�format_percentiles�s,$




r�)rqr]cCs\|j�}t|�}|jdk	rdS|j}|tk}d}tj||t|�dk�j�dk}|rXdSdS)NFi�Qge��ArTg�S$��B)	r`r<�tzrqr r�logical_andr�r�)rq�
values_int�consider_values�
one_day_nanos�	even_daysrZrZr[�_is_dates_only&s
 r�r)r�r�ror]cCsf|dkst|�rt|�r|S|dk	s0t|t�r^t|dd�dk	rPt|�j|�}nt|�j|�}t|�S)Nr)r0r2r�rr�Z
tz_convertZtz_localizera)r�r�rorZrZr[�_format_datetime64;sr�)r�rorpr]cCsF|dkst|�rt|�r|St|t�s.t|�}|r<|j|�S|jSdS)N)r0r2r�r�strftimeZ
_date_repr)r�rorprZrZr[�_format_datetime64_dateonlyJs

r�)�
is_dates_onlyrorpr]cs&|rd��fdd�	Sd�fdd�	SdS)Ncst|��d�S)N)rorp)r�)r�r�)rprorZr[rM^sz(_get_format_datetime64.<locals>.<lambda>cst||�d�S)N)r�ro)r�)r�r�)rorZr[rMbs)N)NrZ)r�rorprZ)rpror[�_get_format_datetime64Ysr�)rqrpr]cCs6t|tj�r|jdkr|j�}t|�}|r2|p0dS|S)z8 given values and a date_format, return a string format r�z%Y-%m-%d)r�rrn�ndimr`r�)rqrpr�rZrZr[rresrrc@seZdZeed�dd�ZdS)r@)r]cs>|jjt�}t|�}|jp&t||jd���fdd�|D�}|S)z we by definition have a TZ )rpcsg|]}�|��qSrZrZ)rir�)rrZr[rk|sz9Datetime64TZFormatter._format_strings.<locals>.<listcomp>)rqr|r^r�rr�rp)rYrqr�rprZ)rr[rIusz%Datetime64TZFormatter._format_stringsN)rtrurvrrarIrZrZrZr[r@tsr@csDeZdZd	eejefeed��fdd�
Z	e
ed�dd�Z�ZS)
rArF)rqro�boxcs t�j|f|�||_||_dS)N)r�r\ror�)rYrqror�r�)r�rZr[r\�szTimedelta64Formatter.__init__)r]cs.|jpt|j|j|jd���fdd�|jD�S)N)ror�csg|]}�|��qSrZrZ)rir�)rrZr[rk�sz8Timedelta64Formatter._format_strings.<locals>.<listcomp>)r�_get_format_timedelta64rqror�)rYrZ)rr[rI�sz$Timedelta64Formatter._format_strings)rF)
rtrurvrrrnr=rarwr\rrIr�rZrZ)r�r[rA�s"rAF)rqror�r]csV|jtj�}|tk}d}tj|||dk�j�dk}|r>d�nd����fdd�}|S)	z�
    Return a formatter function for a range of timedeltas.
    These will all have the same format argument

    If box, then show the return in quotes
    i�Qge��ArN�longcsN|dkst|�rt|�r�St|t�s.t|�}|j�d�}�rJd|�d�}|S)N)r��')r0r2r�rZ
_repr_base)r�rr)r�r�rorZr[rt�s
z+_get_format_timedelta64.<locals>._formatterg�S$��B)r|rZint64r r�r�)rqror�r�r�r�r�rtrZ)r�r�ror[r��sr�)�stringsr@r�r�r]cs�t|�dks|dkr|S�dkr&t��t�fdd�|D���|dk	rNt|���td���dk	rj��krj�����fdd���fdd	�|D�}�j|�|d
�}|S)Nrr1c3s|]}�j|�VqdS)N)r_)rir�)r�rZr[r��sz$_make_fixed_width.<locals>.<genexpr>zdisplay.max_colwidthcs6�dk	r2�dk�j|��k@r2|d�d�d}|S)Nr�z...)r_)r�)r��conf_maxr�rZr[�just�sz_make_fixed_width.<locals>.justcsg|]}�|��qSrZrZ)rir�)r�rZr[rk�sz%_make_fixed_width.<locals>.<listcomp>)r�)r_r�r�rr@)r�r@r�r�rrrZ)r�r�r�r�r[r��s
r�)�
str_complexesr�rUr]cs��fdd�|D�S)z�
    Separates the real and imaginary parts from the complex number, and
    executes the _trim_zeros_float method on each of those.
    cs&g|]}djttjd|������qS)rWz([j+-]))rnrb�rer)rir�)r�rUrZr[rk�sz'_trim_zeros_complex.<locals>.<listcomp>rZ)r�r�rUrZ)r�rUr[ra�sra)�
str_floatsr�rUr]csR|}�fdd����fdd�}x||�r<�fdd�|D�}q W��fdd�|D�S)zM
    Trims zeros, leaving just one before the decimal points if need be.
    cs|�ko|jd�S)N�inf)�endswith)r�)rUrZr[�
_is_number�sz%_trim_zeros_float.<locals>._is_numbercs^�fdd�|D�}�fdd�|D�}t|�dko\t|�o\tdd�|D��o\tdd�|D��S)Ncsg|]}�|�r|�qSrZrZ)rir�)r�rZr[rk�sz4_trim_zeros_float.<locals>._cond.<locals>.<listcomp>csg|]}�|k�qSrZrZ)rir�)r�rZr[rk�srcss|]}|jd�VqdS)�0N)r�)rir�rZrZr[r��sz3_trim_zeros_float.<locals>._cond.<locals>.<genexpr>css|]}d|kpd|kVqdS)�e�ENrZ)rir�rZrZr[r��s)r_r1r�)rqZfiniteZhas_decimal)r�r�rZr[�_cond�sz _trim_zeros_float.<locals>._condcs$g|]}�|�r|dd�n|�qS)Nr�rzrZ)rir�)r�rZr[rksz%_trim_zeros_float.<locals>.<listcomp>cs*g|]"}|j��r"�|�r"|dn|�qS)r�)r�)rir�)r�r�rZr[rksrZ)r�r�rUZtrimmedr�rZ)r�r�rUr[rb�s
rb)r{r]cCs$t|t�rtj|j�S|jdk	SdS)N)r�r9�comZany_not_noner�r|)r{rZrZr[r.s
r.c"@s�eZdZdZd$dd%dd&dd'd	d(dd)d
d*dd+dddddddddd
dddddddddiZd,eeed�dd �Ze	ee
fed!�d"d#�ZdS)-rEzl
    Formats float values according to engineering format.

    Based on matplotlib.ticker.EngFormatter
    �r'��z��a�r�rG�p�	�nrf�ur��mrrWr��M�G�T�Pr��Z�YNF)�accuracy�use_eng_prefixcCs||_||_dS)N)r�r�)rYr�r�rZrZr[r\)szEngFormatter.__init__)�numr]c
Cs"tjt|��}tjj|�rdStjj|�r.dSd}|dkrDd}|}|dkrntjttj|j�d�d��}n
tjd�}|j	t
|jj���}|j
t	|jj���}t|�}|j
r�|j|}n$|dkr�d|d��}nd|d��}||d	|}|jd
k�rd}nd|jd
�d�}|j||d�}	|	S)a�
        Formats a number in engineering notation, appending a letter
        representing the power of 1000 of the original number. Some examples:

        >>> format_eng(0)       # for self.accuracy = 0
        ' 0'

        >>> format_eng(1000000) # for self.accuracy = 1,
                                #     self.use_eng_prefix = True
        ' 1.0M'

        >>> format_eng("-1e-6") # for self.accuracy = 2
                                #     self.use_eng_prefix = False
        '-1.00E-06'

        @param num: the value to represent
        @type num: either a numeric value or a string that can be converted to
                   a numeric value (as per decimal.Decimal constructor)

        @return: engineering formatted string
        rQr�r�rr�zE-Z02dzE+riNz{mant: g}{prefix}z{mant: .rJz
f}{prefix})�mant�prefixrz)r��Decimalra�is_nan�is_infiniter��mathr~rr�r��ENG_PREFIXESr�r�r�r�)
rYr�Zdnum�signZpow10Z	int_pow10r�r�Z
format_str�	formattedrZrZr[�__call__-s4"
zEngFormatter.__call__i��i��i��i�i�i����i�������)NF)
rtrurvr7r�rr�rwr\rrmrar�rZrZrZr[rE
s(r�)r�r�r]cCs(tdt||��tdtd|d��dS)z�
    Alter default behavior on how float is formatted in DataFrame.
    Format float in engineering format. By accuracy, we mean the number of
    decimal digits after the floating point.

    See also EngFormatter.
    zdisplay.float_formatzdisplay.column_spacerGr�N)rrEr�)r�r�rZrZr[�set_eng_float_formatnsr�)�colsr�r]c
Cs�d}g}d}t|�d}xht|�D]\\}}||}||7}||krX|d|koT|dk}	n|d|koj|dk}	|	r"|j|�|}q"W|jt|��|S)Nr�rr�)r_r�ro)
r�r�rZbinsZ
curr_widthZ
i_last_columnrjr�Z
w_adjoined�wraprZrZr[rzs
rrW)r,�sentinelr]c	Cs�t|�dkrgSdgt|d�}g}xn|D]f}d}i}x>t|�D]2\}}||r\||kr\qBd||<||||<|}qBWt|�|||<|j|�q,W|S)a�
    For each index in each level the function returns lengths of indexes.

    Parameters
    ----------
    levels : list of lists
        List of values on for level.
    sentinel : string, optional
        Value which states that no new index starts on there.

    Returns
    -------
    Returns list of maps. For each level returns map of indexes (key is index
    in row and value is length of index).
    rTF)r_r�ro)	r,r��controlrr�level�
last_index�lengthsrj�keyrZrZr[�get_level_lengths�s 
r�)rSr
r]cCs4tdd�|D��r dd�|D�}|jdj|��dS)z�
    Appends lines to a buffer.

    Parameters
    ----------
    buf
        The buffer to write to
    lines
        The lines to append.
    css|]}t|t�VqdS)N)r�ra)rir�rZrZr[r��sz#buffer_put_lines.<locals>.<genexpr>cSsg|]}t|��qSrZ)ra)rir�rZrZr[rk�sz$buffer_put_lines.<locals>.<listcomp>r^N)r�r�rn)rSr
rZrZr[�buffer_put_lines�sr�)rFrGrHr@rIrJrKrLrMrNrO)NrQNNrGr�NN)Nr)rN)rN)rF)rGNN)r�rQ)r�rQ)r�F)rW)�r7�
contextlibr�csvrr�datetimerr��	functoolsr�iorr�r��shutilrZtypingr	r
rrr
rrrrrrrrr�unicodedatarZnumpyrZpandas._config.configrrZpandas._libsrZpandas._libs.missingrZpandas._libs.tslibrZpandas._libs.tslibsrrrr Zpandas._libs.tslibs.nattyper!Zpandas._typingr"r#Z
pandas.errorsr$Zpandas.core.dtypes.commonr%r&r'r(r)r*r+r,r-r.r/r0r1Zpandas.core.dtypes.missingr2r3Zpandas.core.arrays.datetimesr4Zpandas.core.arrays.timedeltasr5Zpandas.core.baser6Zpandas.core.common�core�commonr�Zpandas.core.constructionr7Zpandas.core.indexes.apir8r9r:r;Zpandas.core.indexes.datetimesr<Zpandas.core.indexes.timedeltasr=Zpandas.io.commonr>Zpandas.io.formats.printingr?r@rArrBrCrDrar�r�r<r:r;r8Z_VALID_JUSTIFY_PARAMETERSr9rPrxr�r�r�r�r�rwrerErCrDr?rBrnrmr�r�r�r�r�rrr@rAr�r�rarbr.rEr�rr^r�r�rZrZrZr[�<module>s�@<(*:	@ 'LH6Dd"*B

%
a)