
    VfdV                         d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dl	Z
ddlmZ ddlmZmZ  G d d          Zd	 Zd
dddddddZd Z	 	 d"dZd#dZd$dZd Z	 	 	 d%dZd&dZ	 	 	 d'd Zd(d!ZdS ))    )lzipN)reduce   )SimpleTable)	fmt_latexfmt_txtc                   v    e Zd Zd Zd Zd Zd Zd Z	 	 dd	Zdd
Z	ddZ
d ZddZ	 	 ddZd Zd ZddZdS )Summaryc                 L    g | _         g | _        g | _        d | _        d| _        d S )NF)tablessettings	extra_txttitle_merge_latexselfs    :lib/python3.11/site-packages/statsmodels/iolib/summary2.py__init__zSummary.__init__   s,    
!    c                 *    |                                  S Nas_textr   s    r   __str__zSummary.__str__   s    ||~~r   c                 p    t          t          |                     dz   |                                 z   dz   S )Nz
"""
z
""")strtyper   r   s    r   __repr__zSummary.__repr__   s+    4::*T\\^^;gEEr   c                 *    |                                  S )z$Display as HTML in IPython notebook.as_htmlr   s    r   _repr_html_zSummary._repr_html_   s    ||~~r   c                 *    |                                  S )z9Display as LaTeX when converting IPython notebook to PDF.)as_latexr   s    r   _repr_latex_zSummary._repr_latex_!   s    }}r   T%.4frc                 |    ||||d}| j                             |           | j                            |           dS )a  
        Add the contents of a DataFrame to summary table

        Parameters
        ----------
        df : DataFrame
        header : bool
            Reproduce the DataFrame column labels in summary table
        index : bool
            Reproduce the DataFrame row labels in summary table
        float_format : str
            Formatting to float data columns
        align : str
            Data alignment (l/c/r)
        indexheaderfloat_formatalignN)r   appendr   )r   dfr*   r+   r,   r-   r   s          r   add_dfzSummary.add_df%   sN    $ #f$05B B2X&&&&&r   c                 b    t          j        |          }|                     |dd||           dS )a  Add the contents of a Numpy array to summary table

        Parameters
        ----------
        array : numpy array (2D)
        float_format : str
            Formatting to array if type is float
        align : str
            Data alignment (l/c/r)
        Fr)   N)pd	DataFramer0   )r   arrayr-   r,   tables        r   	add_arrayzSummary.add_array<   sC     U##Eu!-U 	 	< 	< 	< 	< 	<r      lc                    fd|                                 D             }fd|                                D             }t          j        t	          ||                    }|j        d         |z  dk    rA||j        d         |z  z
  }t          j        |t          j        |ddggz            g          }t          j        ||          }t          d |          }| 	                    ||           dS )a  Add the contents of a Dict to summary table

        Parameters
        ----------
        d : dict
            Keys and values are automatically coerced to strings with str().
            Users are encouraged to format them before using add_dict.
        ncols : int
            Number of columns of the output table
        align : str
            Data alignment (l/c/r)
        float_format : str
            Formatting to float data columns
        c                 0    g | ]}t          |          S  
_formatter.0xr,   s     r   
<listcomp>z$Summary.add_dict.<locals>.<listcomp>\   s#    >>>
1l++>>>r   c                 0    g | ]}t          |          S r;   r<   r>   s     r   rA   z$Summary.add_dict.<locals>.<listcomp>]   s#    @@@
1l++@@@r   r    c                 .    t          j        | |g          S r   )nphstackr@   ys     r   <lambda>z"Summary.add_dict.<locals>.<lambda>e   s    29aV#4#4 r   r-   N)
keysvaluesrE   r4   r   shapevstacksplitr   r6   )	r   dncolsr-   r,   rK   valsdatapads	       `    r   add_dictzSummary.add_dictL   s      ?>>>QVVXX>>>@@@@QXXZZ@@@xT4(()):a=5 A%%4:a=501C9dBHSRH:-=$>$>?@@Dxe$$44d;;t5)))))r   c                 :    | j                             |           dS )zAppend a note to the bottom of the summary table. In ASCII tables,
        the note will be wrapped to table width. Notes are not indented.
        N)r   r.   )r   strings     r   add_textzSummary.add_texth   s      	f%%%%%r   Nc                     t          |t                    r	|| _        dS |3|j        j        j        }|t          v rt          |         }d|z   | _        dS d| _        dS )a  Insert a title on top of the summary table. If a string is provided
        in the title argument, that string is printed. If no title string is
        provided but a results instance is provided, statsmodels attempts
        to construct a useful title automatically.
        Nz	Results: rC   )
isinstancer   r   model	__class____name___model_types)r   r   resultsr[   s       r   	add_titlezSummary.add_titlen   sd     eS!! 		 DJJJ"/8L(((/E(50





r   皙?c                     t          |||j                  }t          |          }|||_        |||d<   |                     |d           |                     ||           |                     ||           dS )aL  Try to construct a basic summary instance.

        Parameters
        ----------
        results : Model results instance
        alpha : float
            significance level for the confidence intervals (optional)
        float_format: str
            Float formatting for summary of parameters (optional)
        title : str
            Title of the summary table (optional)
        xname : list[str] of length equal to the number of parameters
            Names of the independent variables (optional)
        yname : str
            Name of the dependent variable (optional)
        )alphause_tNDependent Variable:r8   rJ   )r,   )r   r_   )summary_paramsrd   summary_modelr*   rU   r0   r`   )	r   r_   rc   r,   r   xnameynameparaminfos	            r   add_basezSummary.add_base   s    & we7=IIIW%%EK*/D&'d#&&&E555UG44444r   c                 x   | j         }| j        }| j        }| j        }t	          ||          \  }}dz  }t          ||||          }d |D             }	d                    |	          }	|	                    d          }	||	d<   |	                    |           d                    |	          }	|A|}t          |          k     r+dt          dz  t          |          dz  z
            z  |z   }nd}fd	|D             }
d
 |
D             }
d                    |
          }
d                    ||	|
g          }|S )z%Generate ASCII Summary Table
        =c                 6    g | ]}|                                 S r;   r   r?   r@   s     r   rA   z#Summary.as_text.<locals>.<listcomp>        222qqyy{{222r   
r   N r7   rC   c                 :    g | ]}t          j        |          S r;   )textwrapwrap)r?   r@   widests     r   rA   z#Summary.as_text.<locals>.<listcomp>   s%    ;;;Ax}Q'';;;r   c                 8    g | ]}d                      |          S )rr   )joinrp   s     r   rA   z#Summary.as_text.<locals>.<listcomp>   s"    )))tyy||)))r   )r   r   r   r   _measure_tables_simple_tablesry   rO   r.   lenint)r   r   r   r   r   pad_col	pad_index
rule_equalsimple_tablestabtxtoutrw   s               @r   r   zSummary.as_text   sR    =
N	%4VX%F%F"Fc\
&vx)LL22M222iinniiooA

:iinnE5zzF""c&1*s5zzA~"=>>>FE;;;;;;;))S)))iinniiS)**
r   c                     | j         }| j        }t          ||          }d |D             }d                    |          }d | j        D             }d                    |          }d                    ||g          }|S )z$Generate HTML Summary Table
        c                 6    g | ]}|                                 S r;   r    rp   s     r   rA   z#Summary.as_html.<locals>.<listcomp>   rq   r   rr   c                 :    g | ]}|                     d d          S )rr   <br/>
)replace)r?   sts     r   rA   z#Summary.as_html.<locals>.<listcomp>   s&    HHH2BJJtY//HHHr   r   )r   r   r{   ry   r   )r   r   r   r   r   temp_txtr   r   s           r   r!   zSummary.as_html   s     =&vx8822M222iinnHHHHHnnX&&nnc3Z((
r   rC   c                 v   | j         }| j        }| j        }|	d|z   dz   }nd}d|z   dz   }t          ||          }d |D             }d                    |          }d}| j        rt          j        |d	|          }d
|||df}d                    |          }d                    | j                  }	|dz   |	z   }
|
S )zGenerate LaTeX Summary Table

        Parameters
        ----------
        label : str
            Label of the summary table that can be referenced
            in a latex document (optional)
        Nz	\caption{}z
\caption{}z\label{c                 6    g | ]}|                                 S r;   )as_latex_tabularrp   s     r   rA   z$Summary.as_latex.<locals>.<listcomp>   s$    ;;;q!!##;;;r   z

z8\\hline\n\\hline\n\\end{tabular}\n\\begin{tabular}{.*}\nz\\midrule\nz\begin{table}z\end{table}rr   z \newline 
z

\bigskip
)	r   r   r   r{   ry   r   resubr   )r   labelr   r   r   r   r   
to_replacenon_captionedr   r   s              r   r$   zSummary.as_latex   s     =
 5(3.EE!EU"S(&vx88;;];;;kk#A
  	:&^S99C(%^K		-00""4>22o-3
r   )TTr&   r'   )r'   r&   )r7   r8   r&   NN)ra   r&   NNN)rC   )r]   
__module____qualname__r   r   r   r"   r%   r0   r6   rU   rX   r`   rl   r   r!   r$   r;   r   r   r
   r
      s       " " "  F F F     @F' ' ' '.< < < < * * * *8& & &       " HL#'5 5 5 5:# # #J  $% % % % % %r   r
   c                    t          | |          }d |D             }d |D             }t          |          }g }g }t          t          |                    D ]|}t          | |         j        d         dz
  d          }	t          |||         z
  |	z            }
|                    |
           ||         |	|
z  z   }|                    ||z
             }||t          |          fS )zCompare width of ascii tables in a list and calculate padding values.
    We add space to each col_sep to get us as close as possible to the
    width of the largest table. Then, we add a few spaces to the first
    column to pad the rest.
    c                 6    g | ]}|                                 S r;   r   rp   s     r   rA   z#_measure_tables.<locals>.<listcomp>  s     
.
.
.1199;;
.
.
.r   c                 \    g | ])}t          |                                d                    *S r   )r|   
splitlinesrp   s     r   rA   z#_measure_tables.<locals>.<listcomp>  s-    222c!,,..#$$222r   r   )r{   maxranger|   rM   r}   r.   )r   r   r   r   lengthlen_maxpad_sepr   inseprT   len_news               r   rz   rz      s     #6844M
.
.
.
.
.C22c222F&kkGGI3s88__ , ,6!9?1%)1--7VAY&$.//s)dSj(7*++++Is6{{**r   zOrdinary least squareszGeneralized least squaresz$Generalized least squares with AR(p)zWeighted least squareszRobust linear modelzNegative binomial modelzGeneralized linear model)OLSGLSGLSARWLSRLMNBinGLMc                    d }i }d |d<   d |d<   d |d<   d |d	<   ||d
<   d |d<   d |d<   d |d<   d |d<   d |d<   d |d<   d |d<   d |d<   d |d<   | j         rdnd}d |d |z   d!z   <   d" |d#|z   d!z   <   d$ |d%<   d& |d'<   d( |d)<   d* |d+<   d, |d-<   d. |d/<   d0 |d1<   d2 |d3<   d4 |d5<   d6 |d7<   d8 |d9<   i }|                                D ]1\  }}	  ||           ||<   # t          t          t          f$ r Y .w xY w|S ):z8
    Create a dict with information about the model
    c                  h    t           j                                         }|                    d          S )Nz%Y-%m-%d %H:%M)datetimenowstrftime)argskwdsr   s      r   time_nowzsummary_model.<locals>.time_now$  s)    ##%%||,---r   c                 $    | j         j        j        S r   )r[   r\   r]   r@   s    r   rI   zsummary_model.<locals>.<lambda>)  s    qw09 r   zModel:c                 $    | j         j        j        S r   )family__classr]   r   s    r   rI   zsummary_model.<locals>.<lambda>*  s    ah&6&? r   zModel Family:c                 .    | j         j        j        j        S r   )r   linkr\   r]   r   s    r   rI   zsummary_model.<locals>.<lambda>+  s    qx}'>'G r   zLink Function:c                     | j         j        S r   )r[   endog_namesr   s    r   rI   zsummary_model.<locals>.<lambda>,  s    AG,? r   re   zDate:c                     d| j         z  S Nz%#6d)nobsr   s    r   rI   zsummary_model.<locals>.<lambda>.  s    &16/ r   zNo. Observations:c                     d| j         z  S r   )df_modelr   s    r   rI   zsummary_model.<locals>.<lambda>/  s    &1:"5 r   z	Df Model:c                     d| j         z  S r   )df_residr   s    r   rI   zsummary_model.<locals>.<lambda>0  s    fqz&9 r   zDf Residuals:c                     | j         d         S )N	convergedmle_retvalsr   s    r   rI   zsummary_model.<locals>.<lambda>1  s    1=#= r   z
Converged:c                     | j         d         S )N
iterationsr   r   s    r   rI   zsummary_model.<locals>.<lambda>2  s    l(C r   zNo. Iterations:c                     | j         S r   )methodr   s    r   rI   zsummary_model.<locals>.<lambda>3  s     r   zMethod:c                     | j         d         S )Nnormfit_optionsr   s    r   rI   zsummary_model.<locals>.<lambda>4  s    amF3 r   zNorm:c                     | j         d         S )N	scale_estr   r   s    r   rI   zsummary_model.<locals>.<lambda>5  s    AM+$> r   zScale Est.:c                     | j         d         S )Ncovr   r   s    r   rI   zsummary_model.<locals>.<lambda>6  s    1=#7 r   z
Cov. Type:rC   z (uncentered)c                     d| j         z  S Nz%#8.3f)rsquaredr   s    r   rI   zsummary_model.<locals>.<lambda>9  s    1:8M r   	R-squared:c                     d| j         z  S r   )rsquared_adjr   s    r   rI   zsummary_model.<locals>.<lambda>:  s    X=V r   zAdj. R-squaredc                     d| j         z  S r   )	prsquaredr   s    r   rI   zsummary_model.<locals>.<lambda>;  s    (Q[*@ r   zPseudo R-squared:c                     d| j         z  S Nz%8.4f)aicr   s    r   rI   zsummary_model.<locals>.<lambda><      Wqu_ r   zAIC:c                     d| j         z  S r   )bicr   s    r   rI   zsummary_model.<locals>.<lambda>=  r   r   zBIC:c                     d| j         z  S Nz%#8.5g)llfr   s    r   rI   zsummary_model.<locals>.<lambda>>  s    15(8 r   zLog-Likelihood:c                     d| j         z  S r   )llnullr   s    r   rI   zsummary_model.<locals>.<lambda>?  s    AH!4 r   zLL-Null:c                     d| j         z  S r   )
llr_pvaluer   s    r   rI   zsummary_model.<locals>.<lambda>@  s    X%< r   zLLR p-value:c                     d| j         z  S r   )deviancer   s    r   rI   zsummary_model.<locals>.<lambda>A  s    (QZ"7 r   z	Deviance:c                     d| j         z  S Nz%#6.3g)pearson_chi2r   s    r   rI   zsummary_model.<locals>.<lambda>B  s    h&? r   zPearson chi2:c                     d| j         z  S )Nz%#8.4g)fvaluer   s    r   rI   zsummary_model.<locals>.<lambda>C  s    X%8 r   zF-statistic:c                     d| j         z  S r   )f_pvaluer   s    r   rI   zsummary_model.<locals>.<lambda>D  s    Hqz,A r   zProb (F-statistic):c                     d| j         z  S r   )scaler   s    r   rI   zsummary_model.<locals>.<lambda>E  s    x!'1 r   zScale:)
k_constantitemsAttributeErrorKeyErrorNotImplementedError)r_   r   rk   rsquared_typer   keyfuncs          r   rg   rg     s   
. . . D99DN??DGGD	"?"?D	DM 9 9D	55D99D==DCCD	((DO33DM>>D77D!,ABB/M.M.MD}	$s	*+3V3VD	M	)C	/0 @ @D	,,DL,,DL88D	44D<<D77D??D88D"A"AD	11DN
CZZ\\  	T	tG}}CHH*=> 	 	 	 D	 Js   C))DDra   TFr&   c           
         t          | t                    r
| \  } }}}	}
}n1| j        }| j        }| j        }	| j        }
|                     |          }t          j        |||	|
g          j	        }t          j
        ||g          }t          j        |          }|r7dddddt          |dz            z   t          d|dz  z
            dz   g|_        n6ddd	d
dt          |dz            z   t          d|dz  z
            dz   g|_        |s9	 | j        j        j        |_        n(# t&          $ r | j        j        |_        Y nw xY w||_        |S )ax  create a summary table of parameters from results instance

    Parameters
    ----------
    res : results instance
        some required information is directly taken from the result
        instance
    yname : {str, None}
        optional name for the endogenous variable, default is "y"
    xname : {list[str], None}
        optional names for the exogenous variables, default is "var_xx"
    alpha : float
        significance level for the confidence intervals
    use_t : bool
        indicator whether the p-values are based on the Student-t
        distribution (if True) or on the normal distribution (if False)
    skip_header : bool
        If false (default), then the header row is added. If true, then no
        header row is added.
    float_format : str
        float formatting options (e.g. ".3g")

    Returns
    -------
    params_table : SimpleTable instance
    zCoef.zStd.Err.tzP>|t|[r7   r   ]zzP>|z|)rZ   tupleparamsbsetvaluespvaluesconf_intrE   r4   TrF   r2   r3   r   columnsr[   rS   param_namesr*   r   
exog_names)r_   ri   rh   rc   rd   skip_headerr,   r  r  r  r  r  rS   s                r   rf   rf   Q  su   : '5!! +;B8gwk//##E**8VS'73446D9dH%&&D<D HS'c%!)nn,c!eai-.@.@3.FH  S'c%!)nn,c!eai-.@.@3.FH  	2 +7DJJ 	2 	2 	2 1DJJJ	2 
Ks   
D! !D?>D?c                 ~   t          |           }|j        dd         D ]#}||                             fd          ||<   $d|j        dddf         z   dz   |j        dddf<   |r|j        dddf         dk     }|j        ||j        d	         f         d
z   |j        ||j        d	         f<   |j        dddf         dk     }|j        ||j        d	         f         d
z   |j        ||j        d	         f<   |j        dddf         dk     }|j        ||j        d	         f         d
z   |j        ||j        d	         f<   |j        ddddf         }|                                }|rt          | dt          j                  }t          | dt          j                  }t          j
        ||d          }	|	                                                                r0|	                    fd          }	t          j        ||	gd	          }t          j        |          }t          | j        j                  g|_        |S )z<Stack coefficients and standard errors in single column
    Nr7   c                     | z  S r   r;   r@   r,   s    r   rI   z_col_params.<locals>.<lambda>  s    L1,< r   (r   )   g?r   *ra   g{Gz?r   r   ))r   rC   )zR-squared Adj.rC   c                     | z  S r   r;   r  s    r   rI   z_col_params.<locals>.<lambda>  s    L1$4 r   )axis)rf   r	  applyiloclocstackgetattrrE   nanr2   Seriesnotnullanyconcatr3   r   r[   r   )
resultr,   stars
include_r2rescolidxr   r   r2s
    `        r   _col_paramsr'    sF   
 
 
 C{2A2 > >s8>>"<"<"<"<==C38AAAqD>)C/CHQQQTN Jhqqq!tnr!'*wsCKN/B'Cc'IS[^#$hqqq!tns"'*wsCKN/B'Cc'IS[^#$hqqq!tns"'*wsCKN/B'Cc'IS[^#$
(111bqb5/C
))++C  /6:rv66v~rv>>Y80<> > ? ? ::<< 	/444455B)S"IA...C
,s

Cv|/001CKJr   c                 v   |i }g }g }|D ]~}t          ||         t                    r	 |                     ||         |                      n%# t          $ r |                    d           Y nw xY w|                    |           t	          j        t          | j        j                  |i|          }|S )z!Stack model info in a column
    NrC   )r*   )	rZ   dictr.   r   r2   r3   r   r[   r   )r   	info_dictr   r*   r   s        r   	_col_infor+    s     	
CE  ilD)) 		JJ|y|F++,,,, 	 	 	JJrNNNNN	Q
,FL455s;5
I
I
ICJs   $AA10A1c                     t          t          |                     t          |           k    r| S ddlm}  |t                    }g }| D ]3}||xx         dz  cc<   |                    |dz   ||         z              4|S )Nr   )defaultdictIrs   )r|   setcollectionsr-  r   r.   )list_of_namesr-  name_counterr+   _names        r   _make_uniquer4    s    
3}#m"4"444'''''';s##LF 9 9Us"eckL$778888Mr   r;   c                 B   t          | t                    s| g} fd| D             }|rt          |          }	nt          d |D                       }	t          t	          |                    D ]}
|	|
         g||
         _        d }t          ||          }r|j                            d          	                                t          j                                                  }|j        |dk             j        	                                fdD             }fdD             }||z   fd|j                            d          D             }|z  |r|D ]}                    |           |j                 }g }|j                            d          }t          d|j        d         d          D ]z}
|                    ||
                    |
d	z   |j        d         k     r+||
         ||
d	z            k    r|                    d
           \|                    ||
d	z                       {||_        rfd| D             }nd | D             }t#          |t          d |D                                 D ]\  }}|g|_        d }t          ||          }t          j        t'          j        ||g                    }|j        |_        t          j        |j        	                                |j        	                                z             |_        |}|                    d
          }t/                      }d|_        |                    |dd           |                    d           r|                    d           |S )a@  
    Summarize multiple results instances side-by-side (coefs and SEs)

    Parameters
    ----------
    results : statsmodels results instance or list of result instances
    float_format : str, optional
        float format for coefficients and standard errors
        Default : '%.4f'
    model_names : list[str], optional
        Must have same length as the number of results. If the names are not
        unique, a roman number will be appended to all model names
    stars : bool
        print significance stars
    info_dict : dict, default None
        dict of functions to be applied to results instances to retrieve
        model info. To use specific information for different models, add a
        (nested) info_dict with model name as the key.
        Example: `info_dict = {"N":lambda x:(x.nobs), "R2": ..., "OLS":{
        "R2":...}}` would only show `R2` for OLS regression models, but
        additionally `N` for all other results.
        Default : None (use the info_dict specified in
        result.default_model_infos, if this property exists)
    regressor_order : list[str], optional
        list of names of the regressors in the desired order. All regressors
        not specified will be appended to the end of the list.
    drop_omitted : bool, optional
        Includes regressors that are not specified in regressor_order. If
        False, regressors not specified will be appended to end of the list.
        If True, only regressors in regressor_order will be included.
    include_r2 : bool, optional
        Includes R2 and adjusted R2 in the summary table.
    c                 6    g | ]}t          |           S ))r!  r,   r"  )r'  )r?   r@   r,   r"  r!  s     r   rA   zsummary_col.<locals>.<listcomp>  sG     A A A34 \#-/ / / A A Ar   c                 (    g | ]}|j         d          S r   r	  rp   s     r   rA   zsummary_col.<locals>.<listcomp>  s     < < <!1 < < <r   c                 4    |                      |ddd          S NouterT)howright_index
left_indexmergerG   s     r   mergzsummary_col.<locals>.merg
  &    wwqg4"&  ( ( 	(r   r   r7   c                     g | ]}|v |	S r;   r;   )r?   r@   varnamess     r   rA   zsummary_col.<locals>.<listcomp>  s    ???h1r   c                     g | ]}|v|	S r;   r;   )r?   r@   regressor_orders     r   rA   zsummary_col.<locals>.<listcomp>  s#    EEE1A_,D,DQ,D,D,Dr   c                     g | ]}|v|	S r;   r;   )r?   r@   	new_orders     r   rA   zsummary_col.<locals>.<listcomp>  s-     ( ( (qY&& &&&r   r   rC   c           	      v    g | ]5}t          |                    |j        j        j                            6S r;   )r+  getr[   r\   r]   )r?   r@   r*  s     r   rA   zsummary_col.<locals>.<listcomp>+  sX     I I I;< !Y]]17+<+E+46 6 7 7 I I Ir   c           
      L    g | ]!}t          |t          |d d                    "S )default_model_infosN)r+  r  rp   s     r   rA   zsummary_col.<locals>.<listcomp>.  s;       !	!WQ(=tDDEE   r   c                 (    g | ]}|j         d          S r   r8  )r?   r/   s     r   rA   zsummary_col.<locals>.<listcomp>1  s    +I+I+IbBJqM+I+I+Ir   c                 4    |                      |ddd          S r:  r?  rG   s     r   rA  zsummary_col.<locals>.merg4  rB  r   Tr8   )r+   r-   zStandard errors in parentheses.z* p<.1, ** p<.05, ***p<.01)rZ   listr4  r   r|   r	  r   r*   get_level_valuestolistr2   r  value_countsr  removerM   r.   zipr3   rE   rN   Indexfillnar
   r   r0   rX   )r_   r,   model_namesr!  r*  rF  drop_omittedr"  colscolnamesr   rA  summvcordered	unorderedotheruor%  r*   r/   namerk   datsmryrH  rD  s    ` ``` `                 @@r   summary_colrd    s1   J gt$$ )A A A A A A8?A A AD  >,, < <t < < <==3t99 ( (#A;-Q( ( ( $D #:..q1188::Yx  --//6"'?(//11????o???EEEEEEE	i'	( ( ( (DJ77:: ( ( (U	 	% % %  $$$$x	"
CJ''**E1ek!na(( % %

58EU[^##qU1q5\)A)AJJrNNNNJJuQU|$$$$DJ  I I I I@GI I I    l+I+ID+I+I+IJJKK  DV

( ( ( $D
,ry$..
/
/C,CK**,,tz/@/@/B/BBCCCID;;r??D99DDKKTK---MM3444 42333Kr   c                     	 || z  }n&# t           t          f$ r t          |           }Y nw xY w|                                S r   )
ValueError	TypeErrorr   strip)elementr,   r   s      r   r=   r=   J  sP    W$	"   'll99;;s     ++r'   -c
                   	 |                                  }
	 |
                    fd          }
n(# t          $ r |
                    fd          }
Y nw xY w|r$d |
j                                        D             }nd }|r&	fd|
j                                        D             }n+	fd|
j        d d df         D             |
j        d d df<   d }t          t          j
        |
          ||t          t                    }||j        d         d	<   ||j        d         d
<   ||j        d         d	<   ||j        d         d<   ||j        d         d<   ||j        d         d<   dt          |dz             z  |j        d         d<   |S )Nc                 $    t          |           S r   r<   r  s    r   rI   z$_df_to_simpletable.<locals>.<lambda>W  s    
1l ; ; r   c                 $    t          |           S r   r<   r  s    r   rI   z$_df_to_simpletable.<locals>.<lambda>Y  s    Z<%@%@ r   c                 ,    g | ]}t          |          S r;   )r   rp   s     r   rA   z&_df_to_simpletable.<locals>.<listcomp>[  s    888a3q66888r   c                 T    g | ]$}t          |          t                    d z  z   %S rs   r   r}   r?   r@   r   s     r   rA   z&_df_to_simpletable.<locals>.<listcomp>_  s/    KKK1Q#i..3..KKKr   c                 T    g | ]$}t          |          t                    d z  z   %S rp  rq  rr  s     r   rA   z&_df_to_simpletable.<locals>.<listcomp>a  s?     3 3 3 a&&3y>>C#77 3 3 3r   r   )headersstubsltx_fmttxt_fmtlatexdata_alignsheader_alignr   table_dec_abovetable_dec_belowheader_dec_belowrs   r   colsep)copymapr   applymapr	  rQ  r*   r  r   rE   r4   r   r   output_formatsr}   )r/   r-   r,   r+   r*   r{  r|  r}  r~   r   rb  rt  ru  r   s     `      `    r   _df_to_simpletabler  R  s    ''))CBgg;;;;<< B B Bll@@@@AAB 883;#5#5#7#7888 KKKK	8H8H8J8JKKK3 3 3 3#&8AAAqD>3 3 3A	RXc]]G5&
9 
9 
9B05Bg}-16Bg~..3Be]+2ABe./2ABe./3CBe/0),s7Q;/?/?)?BeX&Is   1 "AAc                 j   g }|r|d         d         nd}|dgt          |           z  }|dgt          |           z  }t          |           D ]d\  }}||         d         }||         d         }	||         d         }
|                    t          ||
||	|||         ||                              e|S )Nr   r,   r&   r*   r+   r-   )r-   r,   r+   r*   r~   r   )r|   	enumerater.   r  )r   r   r~   r   r   r,   r   vr*   r+   r-   s              r   r{   r{   p  s    M2:F8A;~..L#F#C#f++%	&!! I I1G$!X&G$/=I7=U8?
:CA,	H H H 	I 	I 	I 	I
 r   )NNra   TFr&   )r&   TFr   )r&   r;   FNr;   FT)r&   )	r'   r&   TTrj  Nrj  r   r   r   )statsmodels.compat.pythonr   r   	functoolsr   r   ru   numpyrE   pandasr2   r5   r   tableformattingr   r   r
   rz   r^   rg   rf   r'  r+  r4  rd  r=   r  r{   r;   r   r   <module>r     s   * * * * * *        				                / / / / / / / /i i i i i i i iX+ + +4 02?/,11 / / /d FJ399 9 9 9z$ $ $ $N   *
 
 
 EJAFp p p pf    CGHLBC   <     r   