
    A>iF                      % S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
  SSKJr  SSKJr  SSKJr  SSKJr  SS	KrSS	KrSS
KJr  SSKJrJrJrJr  SS	KrSSKJrJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.J/r/J0r0J1r1J2r2J3r3  SSK4J5r5J6r6J7r7  SSK8J9r9J:r:  SSK;J<r<J=r=J>r>J?r?  SSK@JArA  SS	KBJCs  JDrE  SSKFJGrGJHrHJIrIJJrJ  SSKKJLrL  SSKMJNrN  SSKOJPrPJQrQ  SSKRJSrS  \(       a$  SSKTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`  SSKaJbrbJcrc  SrdS\eS '   S!rfS"rgS\eS#'    " S$ S%5      rhSNS& jriSNS' jrj " S( S)5      rk " S* S+5      rl  SO       SPS, jjrm\
 SQ     SRS- jj5       rn         SS                       STS. jjro " S/ S05      rp " S1 S2\p5      rq " S3 S4\p5      rr " S5 S6\p5      rs " S7 S8\p5      rt    SUS9 jruSVS: jrvSWSXS; jjrw  SY       SZS< jjrx SY       S[S= jjry " S> S?\s5      rz " S@ SA\p5      r{  S\       S]SB jjr|   S^         S_SC jjr}S`SaSD jjr~SbSE jr S`     ScSF jjrSdSG jr " SH SI5      r\," SJ5      SeSfSK jj5       r Sg     ShSL jjrSiSM jrg	)jz
Internal module for formatting output data in csv, html, xml,
and latex files. This module also applies to display formatting.
    )annotations)Callable	GeneratorHashableMappingSequence)contextmanager)
QUOTE_NONE)Decimal)partial)StringION)get_terminal_size)TYPE_CHECKINGAnyFinalcast)
get_option
set_option)lib)NA)NaT	Timedelta	Timestamp)NaTType)
set_module)is_complex_dtypeis_float
is_integeris_list_likeis_numeric_dtype	is_scalar)CategoricalDtypeDatetimeTZDtypeExtensionDtype)isnanotna)CategoricalDatetimeArrayExtensionArrayTimedeltaArray)PandasObject)Index
MultiIndexPeriodIndexensure_index)DatetimeIndex)TimedeltaIndex)check_parent_directorystringify_path)printing)	ArrayLikeAxesColspaceArgTypeColspaceTypeCompressionOptionsFilePathFloatFormatTypeFormattersType
IndexLabelSequenceNotStrStorageOptionsWriteBuffer)	DataFrameSeriesa	  
        Parameters
        ----------
        buf : str, Path or StringIO-like, optional, default None
            Buffer to write to. If None, the output is returned as a string.
        columns : array-like, 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. This function must return a unicode string and will be
            applied only to the non-``NaN`` elements, with ``NaN`` being
            handled by ``na_rep``.
        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.
        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.
    r   common_docstring)leftrightcenterjustifyzjustify-allstartendinheritzmatch-parentinitialunsetz
        Returns
        -------
        str or None
            If buf is None, returns the result as a string. Otherwise returns
            None.
    return_docstringc            
          \ rS rSrSrSSSSSSSSSS.	                     SS jjrSS	 jrSS
 jrSS jrSS jr	Sr
g)SeriesFormatter   zP
Implement the main logic of Series.to_string, which underlies
Series.__repr__.
TNaNFN)	lengthheaderindexna_repnamefloat_formatdtypemax_rowsmin_rowsc       	        
   Xl         [        5       U l        X`l        XPl        X0l        X l        X@l        Xl        Xl	        Uc  [        S5      nXpl        Xl        [        R                  " 5       U l        U R!                  5         g )Ndisplay.float_format)seriesr   bufrV   rU   rS   rR   rT   rY   rZ   r   rW   rX   r4   get_adjustmentadj_chk_truncate)selfr]   rR   rS   rT   rU   rV   rW   rX   rY   rZ   s              W/var/www/html/land-tabula/venv/lib/python3.13/site-packages/pandas/io/formats/format.py__init__SeriesFormatter.__init__   sm     :	
  %&<=L(
**,    c                   U   U R                   nU R                  nU=(       a    [        U R                  5      U:  nU R                  nU(       a  [	        [
        U5      nU(       a  [        X5      nUS:X  a  UnUR                  S U nObUS-  n[        U5      n[        R                  " [        R                  " U5      [        R                  " Xe-
  U5      /5      nUR                  U   nXPl        OS U l        X@l        X0l        g )N      )rZ   rY   lenr]   r   intminilocnphstackarange
tr_row_num	tr_seriesis_truncated_vertically)rb   rZ   rY   rs   r]   row_num_len_slices           rc   ra   SeriesFormatter._chk_truncate   s    ==== #+"LDKK0@80K"C*H x21}"Yh/"a-6{YYw'4>4)HI  V,%O"DO'>$rf   c                   U R                   R                  nSnU R                   R                  n[        U[        [
        [        45      (       a  UR                  b  USUR                   3-  nU R                  SLa,  Ub)  U(       a  US-  n[        R                  " USS9nUSU 3-  nU R                  SL d!  U R                  S	:X  a8  U R                  (       a'  U(       a  US-  nUS
[        U R                   5       3-  nU R                  SLa]  U R                  bP  [        U R                   R                  SS 5      nU(       a(  U(       a  US-  nUS[        R                  " U5       3-  n[        U R                   R                  ["        5      (       a4  U R                   R$                  R'                  5       nU(       a  US-  nX&-  n[)        U5      $ )N zFreq: Fz, 	
)escape_charszName: TtruncatezLength: rV   zdtype: r}   )r]   rV   rT   
isinstancer0   r.   r1   freqfreqstrr4   pprint_thingrR   rs   rj   rX   getattrrr   r"   _values_get_repr_footerstr)rb   rV   footerrT   series_name
dtype_name
level_infos          rc   _get_footerSeriesFormatter._get_footer  s   {{!!u}k>JKK

&u}}o..F99E!d&6$"//CUVK{m,,F;;$KK:%$*F*F$T[[!1 233F::U"tzz'= !5!5vtDJdNFGH$9$9*$E#FGG dnn**,<==//@@BJ$ F6{rf   c                    [        U R                  R                  S U R                  U R                  U R
                  S9$ )N)rW   rU   leading_space)format_arrayrr   r   rW   rU   rT   rb   s    rc   _get_formatted_values%SeriesFormatter._get_formatted_values,  s6    NN""**;;**
 	
rf   c                D   U R                   nU R                  5       n[        U5      S:X  a%  [        U R                  5      R
                   SU S3$ UR                  n[        U5      n[        U[        5      (       aH  UR                  SS S9n[        R                  " 5       nUR                  " S/UQ76 R                  S5      nOUR                  SS9nU R!                  5       nU R"                  (       a  SnU R$                  n	['        [(        U	5      n	U R*                  R                  XyS	-
     5      n
U
S
:  a  SnOSnU R*                  R-                  U/U
SS9S   nUR/                  X-   U5        UR/                  U	S	-   S5        U R                  (       a#  U R*                  R                  " S
/US	S  U/Q76 nOU R*                  R                  S
U5      nU R0                  (       a  U(       a  US   S-   U-   nU(       a  USU-   -  n[3        SR5                  U5      5      $ )Nr   z([], )T)include_namessparsifyri   r}   include_namerh      ...z..rF   modery   )rr   r   rj   typer]   __name__rT   
_has_namesr   r-   _format_multir4   r_   adjoinsplit_format_flatr   rs   rq   r   rk   r`   rG   insertrS   r   join)rb   r]   r   rT   have_header	fmt_indexr`   
fmt_valuesn_header_rowsrt   widthdot_strresults                rc   	to_stringSeriesFormatter.to_string5  s   !!#v;!4;;'001vha@@ 'eZ((++$+NI))+C

11y177=I***=I//1
''MooG3(GHHLLaK!89Eqy hh&&y%h&GJGg5w?Wq["-::XX__QE)AB-)DEFXX__Q
3F;;;q\D(61FdVm#F2776?##rf   )r`   r^   rX   rW   rS   rT   rs   rR   rY   rZ   rU   rV   r]   rq   rr   )r]   rB   rR   
bool | strrS   boolrT   r   rU   r   rV   r   rW   
str | NonerX   r   rY   
int | NonerZ   r   returnNoner   r   r   r   r   	list[str])r   
__module____qualname____firstlineno____doc__rd   ra   r   r   r   __static_attributes__ rf   rc   rO   rO      s     "#'## 	
     !    
@?>(T
+$rf   rO   c                     SSK Jn   [        S5      (       a  U R                  5       u  pOSn[        S5      [        S5      [        S5      [        S5      [        S	5      US
.$ )a  Get the parameters used to repr(dataFrame) calls using DataFrame.to_string.

Supplying these parameters to DataFrame.to_string is equivalent to calling
``repr(DataFrame)``. This is useful if you want to adjust the repr output.

Example
-------
>>> import pandas as pd
>>>
>>> df = pd.DataFrame([[1, 2], [3, 4]])
>>> repr_params = pd.io.formats.format.get_dataframe_repr_params()
>>> repr(df) == df.to_string(**repr_params)
True
r   )consolezdisplay.expand_frame_reprNdisplay.max_rowsdisplay.min_rowszdisplay.max_columnsdisplay.max_colwidthdisplay.show_dimensions)rY   rZ   max_colsmax_colwidthshow_dimensions
line_width)pandas.io.formatsr   r   get_console_size)r   r   _s      rc   get_dataframe_repr_paramsr   c  sd     *-..002
A
121245"#9:%&?@  rf   c                     [        5       u  p[        S5      nUS:X  a  UOUnUS:X  a  UO
[        S5      nSSUU[        S5      S.$ )a  Get the parameters used to repr(Series) calls using Series.to_string.

Supplying these parameters to Series.to_string is equivalent to calling
``repr(series)``. This is useful if you want to adjust the series repr output.

Example
-------
>>> import pandas as pd
>>>
>>> ser = pd.Series([1, 2, 3, 4])
>>> repr_params = pd.io.formats.format.get_series_repr_params()
>>> repr(ser) == ser.to_string(**repr_params)
True
r   r   r   Tr   )rV   rX   rZ   rY   rR   )r   r   )r   heightmax_rows_optrY   rZ   s        rc   get_series_repr_paramsr     s\     &'ME01L%*vH%*v
;M0NH 67 rf   c                  v   \ rS rSrSr\(       a  \OSr\\\-   -  r                 S(                                     S)S jjrS*S jr\	S+S j5       r
\	S+S j5       r\	S+S	 j5       r\	S+S
 j5       r\	S,S j5       r\	S+S j5       r\	S+S j5       r\	S+S j5       r\	S+S j5       r\	S-S j5       rS.S jr    S/S jrS0S jrS1S jrS2S jrS3S jrS3S jrS4S jrS+S jrS+S jrS+S jrS-S jrS5S jr S5S jr!S5S jr"S*S  jr#S6S! jr$S7S" jr%S8S# jr&S9S$ jr'S:S% jr(    S;S& jr)S'r*g)<DataFrameFormatteri  z{
Class for processing dataframe formatting options and data.

Used by DataFrame.to_string, which backs DataFrame.__repr__.
ry   Nc                l   Xl         U R                  U5      U l        U R                  U5      U l        X@l        XPl        X`l        U R                  U5      U l	        U R                  U5      U l        U R                  U	5      U l        U R                  U
5      U l        Xl        UU l        UU l        UU l        Xl        Xl        Xl        Xl        U R1                  5       U l        U R5                  5       U l        U R                   U l        U R;                  5         [<        R>                  " 5       U l         g N)!frame_initialize_columnscolumns_initialize_colspace	col_spacerS   rT   rU   _initialize_formatters
formatters_initialize_justifyrG   _validate_float_formatrW   _initialize_sparsifyr   show_index_namesdecimal	bold_rowsescaperY   rZ   r   r   _calc_max_cols_fittedmax_cols_fitted_calc_max_rows_fittedmax_rows_fittedtr_framer   r4   r_   r`   )rb   r   r   r   rS   rT   rU   r   rG   rW   r   index_namesrY   rZ   r   r   r   r   r   s                      rc   rd   DataFrameFormatter.__init__  s    * 
//8229=
55jA//8 77E11(; +"   .#99;#99;

**,rf   c                    U R                  5       nU R                  (       a-  U R                  U R                  5      nUR	                  SU5        U$ )z@
Render a DataFrame to a list of columns (as lists of strings).
r   )_get_strcols_without_indexrT   _get_formatted_indexr   r   )rb   strcols	str_indexs      rc   get_strcolsDataFrameFormatter.get_strcols  s@     113::11$--@INN1i(rf   c                p    U R                   SL =(       d"    U R                   S:H  =(       a    U R                  $ )NTr   )r   is_truncatedr   s    rc   should_show_dimensions)DataFrameFormatter.should_show_dimensions  s3    ##t+ 
  J.D43D3D	
rf   c                R    [        U R                  =(       d    U R                  5      $ r   )r   is_truncated_horizontallyrs   r   s    rc   r   DataFrameFormatter.is_truncated  s    D22Rd6R6RSSrf   c                ~    [        U R                  =(       a"    [        U R                  5      U R                  :  5      $ r   )r   r   rj   r   r   s    rc   r   ,DataFrameFormatter.is_truncated_horizontally  s,    D((Wc$,,.?$BVBV.VXXrf   c                ~    [        U R                  =(       a"    [        U R                  5      U R                  :  5      $ r   )r   r   rj   r   r   s    rc   rs   *DataFrameFormatter.is_truncated_vertically  s+    D((Uc$**o@T@T.TVVrf   c                t    S[        U R                  5       S[        U R                  R                  5       S3$ )Nz

[z rows x z	 columns])rj   r   r   r   s    rc   dimensions_info"DataFrameFormatter.dimensions_info  s0    s4::'xDJJ4F4F0G/H	RRrf   c                @    [        U R                  R                  5      $ r   )r   r   rT   r   s    rc   has_index_names"DataFrameFormatter.has_index_names  s    $****++rf   c                @    [        U R                  R                  5      $ r   )r   r   r   r   s    rc   has_column_names#DataFrameFormatter.has_column_names  s    $**,,--rf   c                Z    [        U R                  U R                  U R                  45      $ r   )allr  rT   r   r   s    rc   show_row_idx_names%DataFrameFormatter.show_row_idx_names  s$    D(($**d6K6KLMMrf   c                Z    [        U R                  U R                  U R                  45      $ r   )r  r  r   rS   r   s    rc   show_col_idx_names%DataFrameFormatter.show_col_idx_names  s$    D))4+@+@$++NOOrf   c                    [        U R                  =(       d    [        U R                  5      [        U R                  5      5      $ r   )rl   rY   rj   r   r   s    rc   max_rows_displayed%DataFrameFormatter.max_rows_displayed
  s(    4==3C

OS_EErf   c                "    Uc  [        S5      $ U$ )Nzdisplay.multi_sparser   )rb   r   s     rc   r   'DataFrameFormatter._initialize_sparsify  s    455rf   c                   Uc  0 $ [        U R                  R                  5      [        U5      :X  d  [        U[        5      (       a  U$ [        S[        U5       S[        U R                  R                  5       S35      e)NzFormatters length(+) should match DataFrame number of columns(r   )rj   r   r   r   dict
ValueError)rb   r   s     rc   r   )DataFrameFormatter._initialize_formatters  sx     I##$J7:jRV;W;W$S_$5 6//24::3E3E/F.GqJ rf   c                "    Uc  [        S5      $ U$ )Nzdisplay.colheader_justifyr  )rb   rG   s     rc   r   &DataFrameFormatter._initialize_justify   s    ?9::Nrf   c                v    Ub!  [        U5      nU R                  U   U l        U$ U R                  R                  $ r   )r/   r   r   )rb   r   colss      rc   r   &DataFrameFormatter._initialize_columns&  s7    (DD)DJK::%%%rf   c                   Uc  0 nU$ [        U[        [        45      (       a?  SU0nUR                  [        R                  U R                  R                  U5      5        U$ [        U[        5      (       aJ  UR                  5        H2  nX0R                  R                  ;  d  M  US:w  d  M&  [        SU 35      e   UnU$ [        U R                  R                  5      [        U5      :w  a8  [        S[        U5       S[        U R                  R                  5       S35      e[	        [        U R                  R                  USS95      nU$ )Nry   z,Col_space is defined for an unknown column: zCol_space length(r  r   Tstrict)r   rk   r   updater  fromkeysr   r   r   keysr  rj   zip)rb   r   r   columns       rc   r   'DataFrameFormatter._initialize_colspace.  s1    F$ # 	C:..)_FMM$--

(:(:IFG  	7++#..*!3!33"$FvhO  +
 F  4::%%&#i.8 'I'7 8336tzz7I7I3J2K1N  #djj00)DIJFrf   c                    U R                  5       (       d  U R                  $ [        5       u  pU R                  U5      (       a  U$ U R                  $ )z%Number of columns fitting the screen.)_is_in_terminalr   r   _is_screen_narrow)rb   r   r   s      rc   r   (DataFrameFormatter._calc_max_cols_fittedF  sE    ##%%== $&!!%((L== rf   c                   U R                  5       (       aT  [        5       u  pU R                  S:X  a  X R                  5       -
  $ U R	                  U5      (       a  UnOU R                  nOU R                  nU R                  U5      $ )z,Number of rows with data fitting the screen.r   )r'  r   rY   _get_number_of_auxiliary_rows_is_screen_short_adjust_max_rows)rb   r   r   rY   s       rc   r   (DataFrameFormatter._calc_max_rows_fittedQ  st     !!)+IA}}! B B DDD$$V,,!==}}H$$X..rf   c                    U(       a@  [        U R                  5      U:  a'  U R                  (       a  [        U R                  U5      nU$ )zAdjust max_rows using display logic.

See description here:
https://pandas.pydata.org/docs/dev/user_guide/options.html#frequently-used-options

GH #37359
)rj   r   rZ   rl   )rb   rY   s     rc   r-  #DataFrameFormatter._adjust_max_rowsd  s2     DJJ(*t}}h7rf   c                ^    [        U R                  S:H  =(       d    U R                  S:H  5      $ )z/Check if the output is to be shown in terminal.r   )r   r   rY   r   s    rc   r'  "DataFrameFormatter._is_in_terminalr  s$    DMMQ&<$--1*<==rf   c                    [        U R                  S:H  =(       a"    [        U R                  R                  5      U:  5      $ Nr   )r   r   rj   r   r   )rb   	max_widths     rc   r(  $DataFrameFormatter._is_screen_narrowv  s/    DMMQ&N3tzz/A/A+BY+NOOrf   c                p    [        U R                  S:H  =(       a    [        U R                  5      U:  5      $ r4  )r   rY   rj   r   )rb   
max_heights     rc   r,  #DataFrameFormatter._is_screen_shorty  s(    DMMQ&G3tzz?Z+GHHrf   c                    SnSnX-   nU R                   (       a&  U[        U R                  R                  5       5      -  nU R                  (       a  US-  nU$ )z?Get number of rows occupied by prompt, dots and dimension info.rh   )r   rj   r   
splitlinesrS   )rb   dot_row
prompt_rownum_rowss       rc   r+  0DataFrameFormatter._get_number_of_auxiliary_rows|  sP    
'D00;;=>>H;;MHrf   c                    U R                   (       a  U R                  5         U R                  (       a  U R                  5         gg)zI
Check whether the frame should be truncated. If so, slice the frame up.
N)r   _truncate_horizontallyrs   _truncate_verticallyr   s    rc   r   DataFrameFormatter.truncate  s3     ))'')''%%' (rf   c                t   U R                   c   eU R                   S-  nUS:  a  [        U R                  R                  5      n[        R
                  " [        R                  " U5      [        R                  " X!-
  U5      /5      nU R                  R                  SS2U4   U l        [        U R                  [        [        45      (       a&  / U R                  SU QU R                  U* S QU l	        O>[        [        U R                  5      nU R                  R                  SS2SU24   U l        Xl        g)zRemove columns, which are not to be displayed and adjust formatters.

Attributes affected:
    - tr_frame
    - formatters
    - tr_col_num
Nri   rh   )r   rj   r   r   rn   ro   rp   rm   r   r   listtupler   rk   r   
tr_col_num)rb   col_numru   rv   s       rc   rA  )DataFrameFormatter._truncate_horizontally  s    ##///&&!+a<t}},,-DYY		' 2BIIdnd4STUF MM..q&y9DM $//D%=99#__Xg.#__gXY/#
 3.G MM..q(7({;DM&rf   c                   U R                   c   eU R                   S-  nUS:  aw  [        U R                  5      n[        R                  " [        R
                  " U5      [        R
                  " X!-
  U5      /5      nU R                  R                  U   U l        O>[        [        U R                  5      nU R                  R                  SU2SS24   U l        Xl
        g)zbRemove rows, which are not to be displayed.

Attributes affected:
    - tr_frame
    - tr_row_num
Nri   rh   )r   rj   r   rn   ro   rp   rm   r   rk   rY   rq   )rb   rt   ru   rv   s       rc   rB  'DataFrameFormatter._truncate_vertically  s     ##///&&!+a<t}}%DYY		' 2BIIdnd4STUF MM..v6DM3.G MM..xx{;DM!rf   c                8  ^  / n[        T R                  5      (       d  T R                  (       d  [        T R                  5       Hj  u  p#T R	                  U5      n[        UT R                  [        T R                  R                  US5      5      T R                  S9nUR                  U5        Ml     U$ [        T R                  5      (       a  [        [        [           T R                  5      T l        [        T R                  5      [        T R                   5      :w  a8  [#        S[        T R                   5       S[        T R                  5       S35      eT R                   Vs/ s H  oU/PM     nnOT R%                  T R                  5      nT R&                  (       a  U H  nUR                  S5        M     [        T R                  5       H  u  p#Xb   n[)        [        T R                  R                  US5      5      /U 4S jU 5       Q76 n	T R	                  U5      n[        UT R                  U	T R                  S9n[)        / U 4S	 jU 5       QU	P76 n
T R                  R                  XT R                  S
9nUR                  X-   5        M     U$ s  snf )Nr   )stringsrG   minimumr`   zWriting z cols but got z aliasesry   c              3  Z   >#    U  H   nTR                   R                  U5      v   M"     g 7fr   r`   rj   .0xrb   s     rc   	<genexpr>@DataFrameFormatter._get_strcols_without_index.<locals>.<genexpr>  s     0R'Qa'   (+)rN  r`   c              3  Z   >#    U  H   nTR                   R                  U5      v   M"     g 7fr   rP  rQ  s     rc   rT  rU    s     @ZDHHLLOOZrV  r   )r   rS   	enumerater   
format_col_make_fixed_widthrG   rk   r   getr`   appendr   rE  r   rj   r   r  _get_formatted_column_labelsr  max)rb   r   icr   labelstr_columnsrS  cheaderheader_colwidthmax_lens   `          rc   r   -DataFrameFormatter._get_strcols_without_index  s   #%DKK((!$--0!__Q/
.& LL 2 21a 89	
 z* 1 N$$tCy$++6DK4;;3t||#44 s4<<01 2"4;;/0:  15<u7K<K;;DMMJK""  ! dmm,DA!nG!DNN&&q!,-0R'0RO +J*DLL/txxJ R@Z@R/RGhh&&wdll&KGNN7/0 - - =s   &Jc           
     ,   U R                   nU R                  U5      n[        UR                  S S 2U4   R                  UU R
                  U R                  U R                  R                  UR                  U   5      U R                  U R                  S9$ )N)rW   rU   spacer   r   )r   _get_formatterr   rm   r   rW   rU   r   r[  r   r   rT   )rb   r_  r   	formatters       rc   rY  DataFrameFormatter.format_col  sz    ''*	JJq!t$$**;;..$$U]]1%56LL**
 	
rf   c                @   [        U R                  [        [        45      (       a0  [	        U5      (       a  [        [        U5      nU R                  U   $ g [	        U5      (       a  XR                  ;  a  U R                  U   nU R                  R                  US 5      $ r   )	r   r   rE  rF  r   r   rk   r   r[  )rb   r_  s     rc   ri  !DataFrameFormatter._get_formatter  ss    dooe}55!}}aLq))!}},,!6LLO??&&q$//rf   c                    SSK Jn  UR                  n[        U[        5      (       a_  UR                  SSS9nU R                  (       a  [        U5      (       a  U" U5      n[        USS06 Vs/ s H  n[        U5      PM     nnU$ UR                  SS9n[        [        X@R                  R                  SS95       VVVs/ s H6  u  nu  pXU R                  U5      (       d  [        U5      (       a  S	U-   OU/PM8     nnnnU$ s  snf s  snnnf )
Nr   )sparsify_labelsF)r   r   r  Tr   r   )pandas.core.indexes.multiro  r   r   r-   r   r   rj   r#  rE  r   rX  r   dtypesri  r    )	rb   r   ro  r   fmt_columnsrS  rb  r_  rX   s	            rc   r]  /DataFrameFormatter._get_formatted_column_labels  s   =--gz**!//e/TK}}[!1!1-k:,/,JT,JK,Jq47,JKK  "..E.BK &/ZZ%6%6uE&	&MAz  ..q116Fu6M6M !G
&  	  L	s   .D=D	c                F   U R                   R                  5        VVs0 s H  u  p#U[        [        U5      _M     nnnUR                  nUR
                  nU R                  S5      n[        U[        5      (       a&  UR                  U R                  U R                  US9nOUR                  U R                  US9/nU V	s/ s H;  n	[        [        [        U	5      SUR!                  SS5      U R"                  S95      PM=     nn	U R"                  R$                  " S/UQ76 R'                  S	5      n
U R(                  (       a*  U R+                  5        V	s/ s H  n	[-        U	5      PM     nn	OS/UR.                  -  nU R0                  (       a  X-   $ U
$ s  snnf s  sn	f s  sn	f )
N	__index__)r   r   rj  )r   rj  rD   ry   r   )rG   rN  r`   rh   r}   )r   itemsr   rk   rT   r   ri  r   r-   r   r   r  r   rF  rZ  rE  r[  r`   r   r   r  _get_column_name_listr   nlevelsrS   )rb   r   kvr   rT   r   fmtr   rS  adjoined
col_headers               rc   r   'DataFrameFormatter._get_formatted_index!  s    261E1E1GH1GQS!_1G	H--!!+.eZ((++"55 , I ""0G0GSV"WI 
  !GVY]]2q5Itxx
  	 
 88??11y177= ""*.*D*D*FG*FQ#a&*FJGJ/J;;((OI I 
 Hs   FAFFc                    / nU R                   R                  n[        U[        5      (       a$  UR	                  S UR
                   5       5        U$ UR                  UR                  c  SOUR                  5        U$ )Nc              3  .   #    U  H  oc  SOUv   M     g 7f)Nry   r   )rR  rV   s     rc   rT  ;DataFrameFormatter._get_column_name_list.<locals>.<genexpr>N  s     P-$|5-s   ry   )r   r   r   r-   extendnamesr\  rV   )rb   r  r   s      rc   rx  (DataFrameFormatter._get_column_name_listJ  sb     "**$$gz**LLP'--PP  LLw||3Frf   c                   Ub  [        U5      (       a  U$ [        U[        5      (       a&  SU;   a  U$  UR                  S5      nUR                  $ [	        S5      e! [        [
        [        4 a  n[	        SU< 35      UeSnAff = f)zd
Validates and processes the float_format argument.
Converts new-style format strings to callables.
N%g      ?z Invalid new-style format string z)float_format must be a string or callable)callabler   r   formatr  KeyError
IndexError)rb   r|  r   es       rc   r   )DataFrameFormatter._validate_float_formatS  s     ;(3--Jc3cz
X

3A::% DEE #Hj9 X$'Gw%OPVWWXs   A B1BB)r`   r   r   r   r   r   rW   r   r   rS   rT   rG   r   r   rY   r   rZ   rU   r   r   r   rG  r   rq   )NNTTrQ   NNNNTNNNF.FT)&r   rA   r   Axes | Noner   ColspaceArgType | NonerS   zbool | SequenceNotStr[str]rT   r   rU   r   r   FormattersType | NonerG   r   rW   FloatFormatType | Noner   bool | Noner   r   rY   r   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   list[list[str]]r   r   r   )r   rk   )r   r  r   r   )r   r  r   r<   )rG   r   r   r   )r   r  r   r,   )r   r  r   r8   )r   r   )rY   r   r   r   r   )r_  rk   r   r   )r_  	str | intr   Callable | None)r   rA   r   r  )r   rA   r   r   )r   zlist[Hashable])r|  r  r   r  )+r   r   r   r   r   rC   rM   rd   r   propertyr   r   r   rs   r   r  r  r  r  r  r   r   r   r   r   r   r   r-  r'  r(  r,  r+  r   rA  rB  r   rY  ri  r]  r   rx  r   r   r   rf   rc   r   r     s    !gbG"222G
  $,0-1,0"/3 $ ###&+'---- -- *	--
 +-- -- -- *-- -- --- -- -- -- -- --  $!--" #--$ %--& '--( 
)--^
 
 

 T T Y Y W W S S , , . . N N P P F F
/	&0	!/&>PI('4"$-^

02'RF)F	Frf   r   c                      \ rS rSrSrS	S jr       S
               SS jjr   S       SS jjr                S                                 SS jjrSr	g)DataFrameRendererik  a  Class for creating dataframe output in multiple formats.

Called in pandas.core.generic.NDFrame:
    - to_csv
    - to_latex

Called in pandas.DataFrame:
    - to_html
    - to_string

Parameters
----------
fmt : DataFrameFormatter
    Formatter with the formatting options.
c                    Xl         g r   r|  )rb   r|  s     rc   rd   DataFrameRenderer.__init__|  s    rf   Nc                    SSK JnJn	  U(       a  U	OUn
U
" U R                  UUUUS9nUR	                  5       n[        XUS9$ )us  
Render a DataFrame to an html table.

Parameters
----------
buf : str, path object, file-like object, or None, default None
    String, path object (implementing ``os.PathLike[str]``), or file-like
    object implementing a string ``write()`` function. If None, the result is
    returned as a string.
encoding : str, default “utf-8”
    Set character encoding.
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 or bool
    When an integer value is provided, it sets the border attribute in
    the opening tag, specifying the thickness of the border.
    If ``False`` or ``0`` is passed, the border attribute will not
    be present in the ``<table>`` tag.
    The default value for this parameter is governed by
    ``pd.options.display.html.border``.
table_id : str, optional
    A css id is included in the opening `<table>` tag if specified.
render_links : bool, default False
    Convert URLs to HTML links.
r   )HTMLFormatterNotebookFormatter)classesbordertable_idrender_linksr^   encoding)pandas.io.formats.htmlr  r  r|  r   save_to_buffer)rb   r^   r  r  notebookr  r  r  r  r  Klasshtml_formatterstrings                rc   to_htmlDataFrameRenderer.to_html  sN    L	

 &.!=HH%
  ))+fAArf   c                d    SSK Jn  U" U R                  US9nUR                  5       n[	        XaUS9$ )u  
Render a DataFrame to a console-friendly tabular output.

Parameters
----------
buf : str, path object, file-like object, or None, default None
    String, path object (implementing ``os.PathLike[str]``), or file-like
    object implementing a string ``write()`` function. If None, the result is
    returned as a string.
encoding: str, default “utf-8”
    Set character encoding.
line_width : int, optional
    Width to wrap a line in characters.
r   )StringFormatter)r   r  )pandas.io.formats.stringr  r|  r   r  )rb   r^   r  r   r  string_formatterr  s          rc   r   DataFrameRenderer.to_string  s3    ( 	=*488
K!++-fAArf   c                Z   SSK Jn  Uc  Sn[        5       nOSnU" S0 SU_SU
_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU	_SU_SU_SU_SU_SU R                  _6nUR	                  5         U(       a9  [        U[        5      (       d   eUR                  5       nUR                  5         U$ g)z+
Render dataframe as comma-separated file.
r   )CSVFormatterNTFpath_or_buflineterminatorsepr  errorscompressionquotingr  index_labelr   	chunksize	quotechardate_formatdoublequote
escapecharstorage_optionsrj  r   )pandas.io.formats.csvsr  r   r|  saver   getvalueclose)rb   r  r  r  r   r  r   r  r  r  r  r  r  r  r  r  r  r  created_buffercsv_formattercontents                        rc   to_csvDataFrameRenderer.to_csv  s   , 	8!N"*K"N$ 
#
)
 
 	

 
 $
 
 
 $
 
  
  
 $
 $
 "
  ,!
" hh#
& 	k84444!**,GNrf   r  )r|  r   r   r   )NNNFNNF)r^   "FilePath | WriteBuffer[str] | Noner  r   r  zstr | list | tuple | Noner  r   r  zint | bool | Noner  r   r  r   r   r   )NNN)r^   r  r  r   r   r   r   r   )NN,NNwinferN"NNNTNr  N)"r  z7FilePath | WriteBuffer[bytes] | WriteBuffer[str] | Noner  r   r  r   r   zSequence[Hashable] | Noner  zIndexLabel | Noner   r   r  r9   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  zStorageOptions | Noner   r   )
r   r   r   r   r   rd   r  r   r  r   r   rf   rc   r  r  k  s    
 37#-1$(#"5B/5B 5B +	5B
 5B "5B 5B 5B 
5Br 37#!%	B/B B 	B
 
B8 PT#-1)-*1"%) $"& !%15#9L9 9 	9
 +9 '9 9 (9 9 9 #9 9  9 9 9  !9" /#9$ 
%9 9rf   r  c                    [        XS9 nUR                  U 5        Uc  UR                  5       sSSS5        $  SSS5        g! , (       d  f       g= f)zI
Perform serialization. Write to buf or return as string if buf is None.
)r  N)_get_bufferwriter  )r  r^   r  fds       rc   r  r    sA     
S	,
;;;=	 
-	,
  
-	,	,s   $AA
Ac              #  r  #    U b  [        U 5      n O
[        5       n Uc  SnO [        U [        5      (       d  [	        S5      e[        U S5      (       a  U v   g[        U [        5      (       a.  [        [        U 5      5        [        U SUSS9 nUv   SSS5        g[        S5      e! , (       d  f       g= f7f)	zt
Context manager to open, yield and close buffer for filenames or Path-like
objects, otherwise yield buf unchanged.
Nzutf-8z1buf is not a file name and encoding is specified.r  r  ry   )r  newlinez1buf is not a file name and it has no write method)	r3   r   r   r   r  hasattrr2   open	TypeError)r^   r  fs      rc   r  r    s      S!jS!!LMMsG 		C		s3x(#sXr:a
 G ;: KLL ;:s   BB7B&B7&
B40B7c                   [         R                  " U R                  S5      (       a  [        n[	        [
        U 5      n O[        U R                  [        5      (       a  [        n[	        [
        U 5      n O[         R                  " U R                  S5      (       a  [        n[	        [        U 5      n O[        U R                  [        5      (       a  [        nO`[         R                  " U R                  S5      (       a  [        nO3[         R                  " U R                  S5      (       a  [        nO[        nUc  SnUc  [!        S5      nUc  [!        S5      nU" U UUUUUUUUU	U
S9nUR#                  5       $ )	a=  
Format an array for printing.

Parameters
----------
values : np.ndarray or ExtensionArray
formatter
float_format
na_rep
digits
space
justify
decimal
leading_space : bool, optional, default True
    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._get_values_for_csv), we don't want the
    leading space since it should be left-aligned.
fallback_formatter

Returns
-------
List[str]
Mmfciu   r\   display.precision)
digitsrU   rW   rj  rh  rG   r   r   r  fallback_formatter)r   is_np_dtyperX   _Datetime64Formatterr   r(   r   r#   _Datetime64TZFormatter_Timedelta64Formatterr*   r$   _ExtensionArrayFormatterFloatArrayFormatter_IntArrayFormatter_GenericArrayFormatterr   
get_result)valuesrj  rW   rU   r  rh  rG   r   r   r  r  	fmt_klassfmt_objs                rc   r   r   B  s)   R v||S))(	mV,	FLL/	2	2*	mV,	s	+	+)	nf-	FLL.	1	1,		t	,	,'		t	,	,&	*	}!"89~/0!#-G rf   c                  ~    \ rS rSr           S                         SS jjrS	S jrS	S jrSrg)
r  i  Nc                    Xl         X l        X@l        XPl        X0l        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        g r   )r  r  rU   rh  rj  rW   rG   r   r  fixed_widthr   r  )rb   r  r  rj  rU   rh  rW   rG   r   r  r  r   r  s                rc   rd   _GenericArrayFormatter.__init__  sD     
"(&*"4rf   c                L    U R                  5       n[        XR                  5      $ r   )_format_stringsrZ  rG   )rb   r   s     rc   r  !_GenericArrayFormatter.get_result  s    ))+
 \\::rf   c                "  ^ ^^ T R                   c   [        S5      nUc  [        S5      mU4S jnOT R                   nT R                  b  T R                  mO[T R                  b  T R                  mOAT R                  S L=(       a    T R                  [
        :g  n[        [        R                  SUS9mUU 4S jnT R                  n[        U[        R                  5      (       d  [        S5      e[        R                  " U[         5      nU[        R"                  " [%        U5      ['        [)        S[+        UR,                  5      5      5      S	9-  nT R.                  nUc  UR1                  5       n/ n[3        U5       H  u  pXi   (       a  T R                  b#  U(       a  UR5                  S
U" U
5       35        M>  Xi   (       a  UR5                  U" U
5      5        M`  USL a  SnOSnUR5                  UR7                  U" U
5      S95        M     U$ )Nr\   r  c                (   > [        U STS S3 5      $ )Nz .dr  )_trim_zeros_single_float)rS  	precisions    rc   <lambda>8_GenericArrayFormatter._format_strings.<locals>.<lambda>  s    )AIa=)**rf   rz   )r~   quote_stringsc                  > TR                   b  [        U 5      (       aq  [        U 5      (       aa  U c  gU [        L a  [	        [        5      $ U [
        L d/  [        U [        R                  [        R                  45      (       a  gTR                   $ [        U [        5      (       a  [	        U 5      $ [	        T" U 5      5      $ )Nr   r   )rU   r!   r%   r   r   r   r   rn   
datetime64timedelta64r+   )rS  rj  rb   s    rc   _format7_GenericArrayFormatter._format_strings.<locals>._format  s    {{&9Q<<DGG9!"Wr7N#XAr~~/N!O!O {{"A|,,1v 9Q<((rf   z=ExtensionArray formatting should use _ExtensionArrayFormatterrh   )axisrp  Fz{v}z {v})r{  )rW   r   rj  r  r  r
   r   r4   r   r  r   rn   ndarrayr  r   	map_inferr   r  r&   rF  rangerj   shaper   anyrX  r\  r  )rb   rW   r  r  valsinferredis_float_typer   r   r_  r{  tplrj  r  s   `           @@rc   r  &_GenericArrayFormatter._format_strings  s   $%&<=L#&':;	   ,,L>>%I$$0//I LL4S9SM%%/+I	) {{$

++O  ==x0ffU4[uU1c$**o-F'GHI 	
 ** )--/M
dODA!$(B!!Agaj\"23!!!,q/2 E)  C C!!#**wqz*":; $ rf   )r   r  r  r  rW   rj  rG   r   rU   r  rh  r  )   NrQ   r  NrE   r  NTTN)r  r5   r  rk   rj  r  rU   r   rh  r  rW   r  rG   r   r   r   r  r   r  r   r   r  r  r  r   r   r   )r   r   r   r   rd   r  r  r   r   rf   rc   r  r    s     %)/3" %).255 5 #	5
 5 5 -5 5 5 5 5 #5 ,5 
58;Drf   r  c                  \   ^  \ rS rSrSU 4S jjr  S     S	S jjrS
S jrSS jrSrU =r	$ )r  i  c                   > [         TU ]  " U0 UD6  U R                  bI  U R                  c;  SU l        [        U R                  5      (       a  U R                  U l        S U l        g g g g NF)superrd   rW   rj  r  r  )rb   argskwargs	__class__s      rc   rd   FloatArrayFormatter.__init__   sh    $)&) (T^^-C$D))**!%!2!2$(! + .D(rf   c                   ^ ^^^^ Tc  T R                   mT(       a  UU 4S jmOU 4S jmT R                  S:w  a  UU 4S jmOTmTc  T$ UU U4S jnU$ )z;Returns a function to be applied on each value to format itc                R   > Tc   e[        U 5      (       a  T" U S9$ TR                  $ )N)value)r&   rU   )r{  rW   rb   s    rc   base_formatter<FloatArrayFormatter._value_formatter.<locals>.base_formatter  s7    #/// Qxx !q) rf   c                R   > [        U 5      (       a  [        U 5      $ TR                  $ r   )r&   r   rU   )r{  rb   s    rc   r  r  +  s    !&qs1v:t{{:rf   r  c                J   > T" U 5      R                  STR                  S5      $ )Nr  rh   )replacer   )r{  r  rb   s    rc   decimal_formatter?FloatArrayFormatter._value_formatter.<locals>.decimal_formatter0  s!    %a(00dllAFFrf   c                z   > [        U 5      (       a  [        U 5      T:  a  T" U 5      $ T" S5      $ TR                  $ )Ng        )r&   absrU   )r  r   rb   	thresholds    rc   rj  7FloatArrayFormatter._value_formatter.<locals>.formatter9  s8    U||u:	),U33,S11{{"rf   )rW   r   )rb   rW   r$  rj  r  r   s   ``` @@rc   _value_formatter$FloatArrayFormatter._value_formatter  sZ     ,,L 	; <<3G !/$$	# rf   c                  ^ ^
^^         SS jm        SS jm
T R                   b(  T" T R                  T R                   T R                  5      $ T R                  (       a  [	        S5      mOSmU
UU U4S jnT R
                  cQ  T R                  (       a3  T R                  SL a  SnOSn[        UR                  T R                  S	9nOT R
                  nOU 4S
 jnU" U5      nT R                  (       d  U$ [        U5      S:  a%  [        S U 5       5      nUT R                  S-   :  nOSn[        R                  " T R                  5      nUS:  R                  5       nUST R                  * -  :  US:  -  R                  5       n	U	(       d  U(       aA  U(       a:  T R                  SL a  SnOSn[        UR                  T R                  S	9nU" U5      nU$ )zp
Returns the float values converted into strings using
the parameters given at initialisation, as a numpy array
c           	        [        U 5      n[        R                  " [        U R	                  5       UR	                  5       SS9 VVs/ s H  u  pEU(       d  U" U5      OUPM     snn5      R                  U R                  5      nU$ s  snnf )NTr  )r%   rn   arrayr#  ravelreshaper  )r  rj  rU   maskvalr  	formatteds          rc   format_with_na_repCFloatArrayFormatter.get_result_as_array.<locals>.format_with_na_repJ  sz     <D #&fllndjjl4"P"P +,IcN7"P
 gfll#  s   B
c           	        [         R                  " U 5      R                  5       n[         R                  " U 5      R                  5       n[	        U5      [	        U5      pe/ n[        U R                  5       UUUUSS9 H  u  ppnU(       d   U(       d  UR                  U" U5      5        M.  U(       d  UR                  U" U	5       SU S35        MT  U(       d]  U" U
5      R                  5       nUR                  S5      (       a  UR                  U U S35        M  UR                  U SU S35        M  UR                  U SU S35        M     [         R                  " U5      R                  U R                  5      $ )NTr  +j-)rn   realr+  imagr%   r#  r\  strip
startswithr*  r,  r  )r  rj  rU   real_valuesimag_values	real_mask	imag_maskformatted_lstr.  real_valimag_valre_isnaim_isnaimag_formatteds                 rc   format_complex_with_na_repKFloatArrayFormatter.get_result_as_array.<locals>.format_complex_with_na_repV  sI    ''&///1K''&///1K#'#4d;6GyM=@>9x' w!((38 !((Ih,?+@&)KL %.x%8%>%>%@N%0055%,,x7Gq-IJ%,,xq8H-JK!((F81VHA)>?)>* 88M*226<<@@rf   Nzdisplay.chop_thresholdc                  > TR                  U T	5      nTR                  S:X  a  STR                  -   OTR                  nTR                  n[	        U5      nU(       a
  T" X1U5      nO	T" X1U5      nTR
                  (       aI  U(       a  [        UTR                  5      nO[        UTR                  5      n[        R                  " USS9$ U$ )NrD   rp  objectrX   )r&  rG   rU   r  r   r  _trim_zeros_complexr   _trim_zeros_floatrn   asarray)
rW   rj  rU   r  
is_complexr   rD  r0  rb   r$  s
         rc   format_values_withCFloatArrayFormatter.get_result_as_array.<locals>.format_values_with}  s    --lIFI +/,,&*@S4;;&dkkF [[F)&1J 3FvN+FvF0FF.vt||DFzz&99Mrf   Tz{value: .{digits:d}f}z{value:.{digits:d}f})r  c                "   > TR                   U -  $ r   )rW   )r  rb   s    rc   r  9FloatArrayFormatter.get_result_as_array.<locals>.<lambda>  s    ):):U)Brf   r   c              3  8   #    U  H  n[        U5      v   M     g 7fr   rj   rR  rS  s     rc   rT  :FloatArrayFormatter.get_result_as_array.<locals>.<genexpr>  s     :)9AQ)9      Fg    .A
   z{value: .{digits:d}e}z{value:.{digits:d}e})r  r5   rj  r   rU   r   r   
np.ndarray)rj  r  rU   r  r   rW   r   r   r  r  rj   r^  rn   r#  r	  )rb   rM  fmt_strrW   formatted_valuesmaxlentoo_longabs_valshas_large_valueshas_small_valuesrD  r0  r$  s   `         @@@rc   get_result_as_array'FloatArrayFormatter.get_result_as_arrayD  s   
	
	*2
	<?
	
		A	A*2	A<?	A	A< >>%%dkk4>>4;;OO"#;<II	 	< $%%-5G4G&w~~dkkJ#00BL-l;##  1$:)9::Fa/HH66$++& %sN//1%|(<<ANSSU-=!!T)10"7>>$++FL1,?rf   c                4    [        U R                  5       5      $ r   )rE  r`  r   s    rc   r  #FloatArrayFormatter._format_strings  s    D,,.//rf   )r  rW   rj  r   NN)rW   r  r$  zfloat | Noner   r   )r   rX  r   )
r   r   r   r   rd   r&  r`  r  r   __classcell__r  s   @rc   r  r    sC    
) 04"&6,6  6 
	6pA F0 0rf   r  c                      \ rS rSrSS jrSrg)r  i  c                    U R                   SL a  S nOS nU R                  =(       d    UnU R                   Vs/ s H
  o2" U5      PM     nnU$ s  snf )NFc                $    U S R                  U S9$ )Nr  rS  r  rj  s    rc   r  4_IntArrayFormatter._format_strings.<locals>.<lambda>  s    1ooo&:rf   c                $    U S R                  U S9$ )Nz drj  rk  rj  s    rc   r  rl    s    2&6&6&6&;rf   )r   rj  r  )rb   formatter_strrj  rS  r   s        rc   r  "_IntArrayFormatter._format_strings  sO    &:M;MNN3m	,0KK8KqilK
8 9s   Ar   Nr   )r   r   r   r   r  r   r   rf   rc   r  r    s    rf   r  c                  X   ^  \ rS rSr% S\S'     S       SU 4S jjjrS	S jrSrU =r$ )
r  i  r(   r  c                @   > [         TU ]  " U40 UD6  X l        X0l        g r   )r  rd   nat_repr  )rb   r  rr  r  r  r  s        rc   rd   _Datetime64Formatter.__init__  s"     	*6*&rf   c                    U R                   nU R                  b!  U Vs/ s H  o R                  U5      PM     sn$ UR                  U R                  U R                  S9nUR                  5       $ s  snf )z&we by definition have DO NOT have a TZ)rU   r  )r  rj  _format_native_typesrr  r  tolist)rb   r  rS  r   s       rc   r  $_Datetime64Formatter._format_strings  sk    >>%/56v!NN1%v6600<<T-=-= 1 

   "" 7s   A/)r  rr  r   N)r  r(   rr  r   r  r   r   r   r   	r   r   r   r   __annotations__rd   r  r   re  rf  s   @rc   r  r    sK    
  		'	' 	' 		' 
	' 	'
# 
#rf   r  c                  *    \ rS rSr% S\S'   SS jrSrg)r  i  r)   r  c                   U R                   nU R                  nS nUc  UR                  SS9n[        U[        5      (       a  UR                  5       nO[        R                  " U[        S9n[        UUU R                  U R                  U R                  U R                  U R                  U R                  U R                   U R"                  US9nU$ )NT)boxedrH  )	rW   rU   r  rh  rG   r   r   r  r  )r  rj  
_formatterr   r'   _internal_get_valuesrn   rK  rG  r   rW   rU   r  rh  rG   r   r   r  )rb   r  rj  r  r*  r   s         rc   r  (_ExtensionArrayFormatter._format_strings  s    NN	!!'!2!2!2!>fk**//1EJJvV4E!**;;;;**LLLL,,LL1

 rf   r   Nr   r   r   r   r   rz  r  r   r   rf   rc   r  r    s    rf   r  c                   [        U 5      S:X  a  / $ [        R                  " U 5      n [        U 5      (       a<  [        R                  " U S:  5      (       a  [        R                  " U S:*  5      (       d  [        S5      eSU -  n [        U 5      nU R                  U5      R                  [        5      n[        R                  " X 5      n[        R                  " U5      (       a*  UR                  [        5      nU Vs/ s H  oUS-   PM	     sn$ [        R                  " U 5      n[        U5      n[        R                  " U [        S9nX   R                  5       R                  [        5      R                  [        5      XC'   X)    R                  U5      R                  [        5      XC) '   U Vs/ s H  oUS-   PM	     sn$ s  snf s  snf )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%']
r   rh   z/percentiles should all be in the interval [0,1]d   r  rH  )rj   rn   rK  r    r  r  get_precisionroundastyperk   iscloser   unique
empty_likerG  )percentilesprecpercentiles_round_typeint_idxoutr_  unique_pctss          rc   format_percentilesr    so   D ;1	**[)K [))vvkQ&''vvkQ&''JKK#K%D(..t4;;C@jj/=G	vvg$++C0!$%AC%%))K(K%D
--6
2C'--/66s;BB3GCL)//5<<SACM !SGS!! & "s   =G0Gc                H   U S   S:  a  U S   OS nU S   S:  a  SU S   -
  OS n[         R                  " XUS9n[        U5      n[         R                  " [         R                  " [         R
                  " U5      5      5      R                  [        5      * n[        SU5      nU$ )Nr   r  )to_beginto_endrh   )	rn   ediff1dr#  floorlog10rl   r  rk   r^  )r*  r  r  diffr  s        rc   r  r  T  s     8a<uQxTH %b	CS59_TF::ev>Dt9DHHRXXbffTl+,33C88Dq$<DKrf   c                .    U [         L a  U$ [        U 5      $ r   )r   r   rS  rr  s     rc   _format_datetime64r  ^  s    Cx q6Mrf   c                x    [        U [        5      (       a  U$ U(       a  U R                  U5      $ U R                  $ r   )r   r   strftime
_date_repr)rS  rr  r  s      rc   _format_datetime64_dateonlyr  g  s4    
 !Wzz+&& ||rf   c                .   ^^ U (       a  UU4S j$ U4S j$ )zYReturn a formatter callable taking a datetime64 as input and providing
a string as outputc                   > [        U TTS9$ )N)rr  r  )r  )rS  r  rr  s    rc   r  'get_format_datetime64.<locals>.<lambda>}  s    4wK
rf   c                   > [        U TS9$ )Nrr  )r  r  s    rc   r  r    s    +Aw?rf   r   )is_dates_onlyrr  r  s    ``rc   get_format_datetime64r  v  s     
 	
 @?rf   c                  *    \ rS rSr% S\S'   SS jrSrg)r  i  r(   r  c                    U R                   R                  nU R                   R                  [        5      nU R                  =(       d    [        XR                  S9nU Vs/ s H
  oC" U5      PM     nnU$ s  snf )zwe by definition have a TZ)r  )r  _is_dates_onlyr  rG  rj  r  r  )rb   idor  rj  rS  r   s         rc   r  &_Datetime64TZFormatter._format_strings  si    kk((##F+NN 
&;--'
	 -33FqilF
3 4s    A5r   Nr   r  r   rf   rc   r  r    s    	rf   r  c                  R   ^  \ rS rSr% S\S'    S     SU 4S jjjrS	S jrSrU =r$ )
r  i  r*   r  c                4   > [         TU ]  " U40 UD6  X l        g r   )r  rd   rr  )rb   r  rr  r  r  s       rc   rd   _Timedelta64Formatter.__init__  s     	*6*rf   c                    U R                   =(       d    [        U R                  U R                  SS9nU R                   Vs/ s H
  o!" U5      PM     sn$ s  snf )NF)rr  box)rj  get_format_timedelta64r  rr  )rb   rj  rS  s      rc   r  %_Timedelta64Formatter._format_strings  sI    NN 
&<KK5'
	 '+kk2k	!k222s   Ar  r   )r  r*   rr  r   r   r   r   ry  rf  s   @rc   r  r    s>    
  
 
 3 3rf   r  c                L   ^^^ U R                   nU(       a  SmOSmUUU4S jnU$ )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
Nlongc                   > U b   [        U 5      (       a  [        U 5      (       a  T$ [        U [        5      (       d  [        U 5      n U R	                  TS9nT(       a  SU S3nU$ )Nrk  ')r!   r%   r   r   
_repr_base)rS  r   r  r  rr  s     rc   r~  *get_format_timedelta64.<locals>._formatter  sZ    91$q''N!Y''!A V,]Frf   )r  )r  rr  r  	even_daysr~  r  s    ``  @rc   r  r    s*     %%I rf   c                R  ^^^	 [        U 5      S:X  d  US:X  a  U $ Uc  [        R                  " 5       mOUm[        U4S jU  5       5      m	Ub  [        UT	5      m	[	        S5      mTb  T	T:  a  Tm	SUUU	4S jjnU  Vs/ s H
  oT" U5      PM     n nTR                  U T	US9nU$ s  snf )Nr   r  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr   rR  )rR  rS  
adjustments     rc   rT  $_make_fixed_width.<locals>.<genexpr>  s     5W*..##Ws   !r   c                b   > Tb*  TS:  TR                  U 5      T:  -  (       a  U S TS-
   S-   n U $ )Nr   r   rR  )rS  r  conf_maxre  s    rc   just_make_fixed_width.<locals>.just  s=    1!2W!<=m!$u,rf   r   )rS  r   r   r   )rj   r4   r_   r^  r   rG   )
rM  rG   rN  r`   r  rS  r   r  r  re  s
          @@@rc   rZ  rZ    s     7|qGu,
{,,.

5W55Ggw'01H( 2  !((1tAwG(w?FM )s   >B$c                   / / p2U  H`  n[         R                  " SU5      nUR                  SR                  USS 5      5        UR                  SR                  USS 5      5        Mb     [	        U 5      n[        X#-   U5      n[	        U5      S:X  a  / $ [        S U 5       5      S-
  n[        USU XvS S	S
9 V	V
s/ s H  u  pU	U
S   -   U
SS SU 3 -   S-   PM     nn	n
U$ s  sn
n	f )z}
Separates the real and imaginary parts from the complex number, and
executes the _trim_zeros_float method on each of those.
z(?<!e)([j+-])ry   Nr   c              3  8   #    U  H  n[        U5      v   M     g 7fr   rR  )rR  parts     rc   rT  &_trim_zeros_complex.<locals>.<genexpr>  s     ;ldD		lrU  rh   Tr  >r4  )rer   r\  r   rj   rJ  r^  r#  )str_complexesr   	real_part	imag_partrS  trimmednpadded_partspadded_lengthreal_ptimag_ptpaddeds               rc   rI  rI    s    
 ry
 ((+Q/"./B01  	MA$Y%:GDL
<A	;l;;a?M !$L!$4l26Ft T
 !UG	 	
!*	QR[=/)*	, 	 !U   Ms   <"C#c                ^    U R                  S5      n U R                  S5      (       a  U S-  n U $ )zL
Trims trailing zeros after a decimal point,
leaving just one if necessary.
0r  )rstripendswith)	str_floats    rc   r  r    s5    
   %I#S	rf   c                j  ^^ U n[         R                  " SU S35      mSU4S jjmS	U4S jjnU" U5      (       a3  U Vs/ s H  nT" U5      (       a  USS OUPM     nnU" U5      (       a  M3  U Vs/ s H-  nT" U5      (       a  UR                  U5      (       a  US-   OUPM/     nnU$ s  snf s  snf )
zy
Trims the maximum number of trailing zeros equally from
all numbers containing decimals, leaving just one if
necessary.
z^\s*[\+-]?[0-9]+\z[0-9]*$c                6   > [         R                  " TU 5      S L$ r   )r  match)rS  number_regexs    rc   is_number_with_decimal1_trim_zeros_float.<locals>.is_number_with_decimal#  s    xxa(44rf   c                   > U  Vs/ s H  nT" U5      (       d  M  UPM     nn[        U5      S:  =(       a    [        S U 5       5      $ s  snf )z
Determine if an array of strings should be trimmed.

Returns True if all numbers containing decimals (defined by the
above regular expression) within the array end in a zero, otherwise
returns False.
r   c              3  B   #    U  H  oR                  S 5      v   M     g7f)r  N)r  rS  s     rc   rT  9_trim_zeros_float.<locals>.should_trim.<locals>.<genexpr>/  s     'IA

3   )rj   r  )r  rS  numbersr  s      rc   should_trim&_trim_zeros_float.<locals>.should_trim&  sF     %Bf(>q(A1fB7|aIC'I'I$II Cs
   A
A
Nr  r  r  )r  ArrayLike | list[str]r   r   )r  compiler  )
str_floatsr   r  r  rS  r   r  r  s         @@rc   rJ  rJ    s     G::!27)7CDL5	J g

GNOw!3A661Sb6A=wO g

 A *!,,G1D1DC!K   M Ps    B+34B0c                    [        U [        5      (       a  [        R                  " U R                  6 $ U R
                  S L$ r   )r   r-   comany_not_noner  rV   )rT   s    rc   r   r   <  s3    %$$--zz%%rf   c                      \ rS rSrSr0 SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$_r S)     S*S& jjrS+S' jrS(rg%),EngFormatteriC  z`
Formats float values according to engineering format.

Based on matplotlib.ticker.EngFormatter
iyiziair  ipir  iur  r   ry   r   rz  rV  r  	   Gr  T   P   E   Z   YNc                    Xl         X l        g r   accuracyuse_eng_prefix)rb   r  r  s      rc   rd   EngFormatter.__init___  s     !,rf   c                   [        [        U5      5      n[         R                  " U5      (       a  g[         R                  " U5      (       a  gSnUS:  a  SnU* nUS:w  a=  [        [	        [
        R                  " UR                  5       S-  5      S-  5      5      nO[        S5      nUR                  [        U R                  R                  5       5      5      nUR                  [        U R                  R                  5       5      5      n[	        U5      nU R                  (       a  U R                  U   nOUS:  a  SU* S 3nOS	US 3nX2-  S
U-  -  nU R                  c  SnOSU R                  S S3nUR                  XvS9n	U	$ )aq  
Formats a number in engineering notation, appending a letter
representing the power of 1000 of the original number. Some examples:
>>> format_eng = EngFormatter(accuracy=0, use_eng_prefix=True)
>>> format_eng(0)
' 0'
>>> format_eng = EngFormatter(accuracy=1, use_eng_prefix=True)
>>> format_eng(1_000_000)
' 1.0M'
>>> format_eng = EngFormatter(accuracy=2, use_eng_prefix=False)
>>> format_eng("-1e-6")
'-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
rQ   infrh   r   r  r   zE-02dzE+rW  z{mant: g}{prefix}z{mant: .r  z
f}{prefix})mantprefix)r   r   is_nanis_infiniterk   mathr  r  rl   r^  ENG_PREFIXESr"  r  r  r  )
rb   numdnumsignpow10	int_pow10r	  r  
format_strr/  s
             rc   __call__EngFormatter.__call__e  sa   ( s3x >>$t$$!8D5D19C

4::<!+; <q @ABEAJE		#d//44678		#d//44678J	&&y1F]9*S)*F)C)F{b%i(== ,J$T]]1$5]CJ%%4%?	rf   r  r  )r  r   r  r   r   r   )r  floatr   r   )	r   r   r   r   r   r  rd   r  r   r   rf   rc   r  r  C  s    SS 	S 	S	
 	S 	C 	C 	C 	
2 	
3 	
3 	
3 	C 	C 	C  	C!" 	C#L* CH-"-;?-	-;rf   r  pandasc                .    [        S[        X5      5        g)a  
Format float representation in DataFrame with SI notation.

Sets the floating-point display format for ``DataFrame`` objects using engineering
notation (SI units), allowing easier readability of values across wide ranges.

Parameters
----------
accuracy : int, default 3
    Number of decimal digits after the floating point.
use_eng_prefix : bool, default False
    Whether to represent a value with SI prefixes.

Returns
-------
None
    This method does not return a value. it updates the global display format
    for floats in DataFrames.

See Also
--------
set_option : Set the value of the specified option or options.
reset_option : Reset one or more options to their default value.

Examples
--------
>>> df = pd.DataFrame([1e-9, 1e-3, 1, 1e3, 1e6])
>>> df
              0
0  1.000000e-09
1  1.000000e-03
2  1.000000e+00
3  1.000000e+03
4  1.000000e+06

>>> pd.set_eng_float_format(accuracy=1)
>>> df
         0
0  1.0E-09
1  1.0E-03
2  1.0E+00
3  1.0E+03
4  1.0E+06

>>> pd.set_eng_float_format(use_eng_prefix=True)
>>> df
        0
0  1.000n
1  1.000m
2   1.000
3  1.000k
4  1.000M

>>> pd.set_eng_float_format(accuracy=1, use_eng_prefix=True)
>>> df
      0
0  1.0n
1  1.0m
2   1.0
3  1.0k
4  1.0M

>>> pd.set_option("display.float_format", None)  # unset option
r\   N)r   r  r  s     rc   set_eng_float_formatr    s    D %|H'MNrf   c                   [        U 5      S:X  a  / $ S/[        U S   5      -  n/ nU  HX  nSn0 n[        U5       H!  u  pxX'   (       a  X:X  a  M  SX''   Xu-
  Xe'   UnM#     [        U5      U-
  Xe'   UR                  U5        MZ     U$ )am  
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).
r   TF)rj   rX  r\  )	levelssentinelcontrolr   level
last_indexlengthsr_  keys	            rc   get_level_lengthsr"    s    $ 6{a	fs6!9~%GF
&FAzco"
&'n#
 ' "%j:5g   Mrf   c                    [        S U 5       5      (       a  U Vs/ s H  n[        U5      PM     nnU R                  SR                  U5      5        gs  snf )zq
Appends lines to a buffer.

Parameters
----------
buf
    The buffer to write to
lines
    The lines to append.
c              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )r   r   rS  s     rc   rT  #buffer_put_lines.<locals>.<genexpr>  s     
-u!:aur  r}   N)r	  r   r  r   )r^   linesrS  s      rc   buffer_put_linesr'    sG     
-u
---!&'AQ'IIdii (s   A)r   zdict[str, Any]rd  )r  r   r^   r  r  r   r   r   r   )r^   r  r  r   r   z1Generator[WriteBuffer[str]] | Generator[StringIO])	NrQ   NNrE   r  TNN)r  r5   rj  r  rW   r  rU   r   r  r   rh  zstr | int | NonerG   r   r   r   r   r  r  r   r  r  r   r   )r  np.ndarray | Sequence[float]r   r   )r*  r(  r   rk   r  )rS  NaTType | Timestamprr  r   r   r   rx  )rS  r)  rr  r   r  r   r   r   )r  r   rr  r   r  r   r   r   )r   F)r  r*   rr  zstr | floatr  r   r   r   )rE   NN)
rM  r   rG   r   rN  r   r`   zprinting._TextAdjustment | Noner   r   )r  )r  r5   r   r   r   r   )r  r   r   r   )r  r  r   r   r   r   )rT   r,   r   r   )r   F)r  rk   r  r   r   r   )ry   )r  r   r  zbool | object | strr   zlist[dict[int, int]])r^   zWriteBuffer[str]r&  r   r   r   )r   
__future__r   collections.abcr   r   r   r   r   
contextlibr	   csvr
   r   r   	functoolsr   ior   r  r  shutilr   typingr   r   r   r   numpyrn   pandas._config.configr   r   pandas._libsr   pandas._libs.missingr   pandas._libs.tslibsr   r   r   pandas._libs.tslibs.nattyper   pandas.util._decoratorsr   pandas.core.dtypes.commonr   r   r   r   r    r!   pandas.core.dtypes.dtypesr"   r#   r$   pandas.core.dtypes.missingr%   r&   pandas.core.arraysr'   r(   r)   r*   pandas.core.baser+   pandas.core.commoncorecommonr  pandas.core.indexes.apir,   r-   r.   r/   pandas.core.indexes.datetimesr0   pandas.core.indexes.timedeltasr1   pandas.io.commonr2   r3   r   r4   pandas._typingr5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   r  rA   rB   rC   rz  VALID_JUSTIFY_PARAMETERSrM   rO   r   r   r   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  rZ  rI  r  rJ  r   r  r  r"  r'  r   rf   rc   <module>rG     s  
 #  &      	 $  
  # 
 0 .  

  *      8 9 '   6 % 6p  % c$ c$L>:IF IFX^ ^F /3	+  	  DHM	+M7AM6M MP ,0"!%*.R R R  )R  	R 
 R  R  R  R  R  R  (R  R je ePI00 I0X/ #1 #65 B?"-?"?"D "  		  JN@@"%@<F@@1 32 3, ! 
 	H +/	  
)	
 DB	 7:!%!03!!H&] ]@ HAO AOJ 24((.((V rf   