U
    Ãmœd�V  ã                	   @   sà   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„ dƒZd	d
„ ZddddddddœZdd„ Zd,dd„Zd-dd„Zd.dd„Zdd „ Zd/d"d#„Zd0d$d%„Zd1d(d)„Zd2d*d+„ZdS )3é    )ÚlzipN)Úreduceé   )ÚSimpleTable)Ú	fmt_latexÚfmt_txtc                   @   sˆ   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zd%dd„Zd&dd„Z	d'dd„Z
dd„ Zd(dd„Zd)dd„Zdd„ Zd d!„ Zd*d#d$„ZdS )+ÚSummaryc                 C   s"   g | _ g | _g | _d | _d| _d S )NF)ÚtablesÚsettingsÚ	extra_txtÚtitleÚ_merge_latex©Úself© r   úS/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/iolib/summary2.pyÚ__init__   s
    zSummary.__init__c                 C   s   |   ¡ S ©N©Úas_textr   r   r   r   Ú__str__   s    zSummary.__str__c                 C   s   t t| ƒƒd |  ¡  d S )Nz
"""
z
""")ÚstrÚtyper   r   r   r   r   Ú__repr__   s    zSummary.__repr__c                 C   s   |   ¡ S )z$Display as HTML in IPython notebook.©Úas_htmlr   r   r   r   Ú_repr_html_   s    zSummary._repr_html_c                 C   s   |   ¡ S )z9Display as LaTeX when converting IPython notebook to PDF.)Úas_latexr   r   r   r   Ú_repr_latex_!   s    zSummary._repr_latex_Tú%.4fÚrc                 C   s*   ||||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
   r   r   r   Úadd_df%   s     ÿzSummary.add_dfc                 C   s"   t  |¡}| j|d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Ú	DataFramer(   )r   Úarrayr%   r$   Útabler   r   r   Ú	add_array<   s
    

 ÿzSummary.add_arrayé   Úlc           	         sª   ‡ fdd„|  ¡ D ƒ}‡ fdd„| ¡ D ƒ}t t||ƒ¡}|jd | dkr~||jd |  }t |t |ddgg ¡g¡}t ||¡}tdd„ |ƒ}| j	||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                    s   g | ]}t |ˆ ƒ‘qS r   ©Ú
_formatter©Ú.0Úx©r$   r   r   Ú
<listcomp>\   s     z$Summary.add_dict.<locals>.<listcomp>c                    s   g | ]}t |ˆ ƒ‘qS r   r0   r2   r5   r   r   r6   ]   s     r   Ú c                 S   s   t  | |g¡S r   )ÚnpÚhstack©r4   Úyr   r   r   Ú<lambda>e   ó    z"Summary.add_dict.<locals>.<lambda>©r%   N)
ÚkeysÚvaluesr8   r+   r   ÚshapeÚvstackÚsplitr   r-   )	r   ÚdZncolsr%   r$   r?   ÚvalsÚdataÚpadr   r5   r   Úadd_dictL   s    zSummary.add_dictc                 C   s   | j  |¡ dS )z”Append 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   Ústringr   r   r   Úadd_texth   s    zSummary.add_textNc                 C   sJ   t |tƒr|| _n4|dk	r@|jjj}|tkr4t| }d| | _n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: r7   )Ú
isinstancer   r   ÚmodelÚ	__class__Ú__name__Ú_model_types)r   r   ÚresultsrL   r   r   r   Ú	add_titlen   s    

zSummary.add_titleçš™™™™™©?c           	      C   sd   t |||jd�}t|ƒ}|dk	r&||_|dk	r6||d< | j|dd� | j||d� | j||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:r/   r>   r5   )r   rP   )Úsummary_paramsrT   Úsummary_modelr"   rH   r(   rQ   )	r   rP   rS   r$   r   ÚxnameÚynameÚparamÚinfor   r   r   Úadd_base   s    zSummary.add_basec                    sø   | j }| j}| j}| j}t||ƒ\}}‰ ˆ d }t||||ƒ}dd„ |D ƒ}	d |	¡}	|	 d¡}	||	d< |	 |¡ d |	¡}	|dk	r¶|}t	|ƒˆ k rºdt
ˆ d t	|ƒd  ƒ | }nd	}‡ fd
d„|D ƒ}
dd„ |
D ƒ}
d |
¡}
d ||	|
g¡}|S )z%Generate ASCII Summary Table
        ú=c                 S   s   g | ]}|  ¡ ‘qS r   r   r2   r   r   r   r6   ª   s     z#Summary.as_text.<locals>.<listcomp>Ú
r   Nú r.   r7   c                    s   g | ]}t  |ˆ ¡‘qS r   )ÚtextwrapÚwrapr2   ©Zwidestr   r   r6   ¹   s     c                 S   s   g | ]}d   |¡‘qS )r^   )Újoinr2   r   r   r   r6   º   s     )r	   r
   r   r   Ú_measure_tablesÚ_simple_tablesrc   rC   r&   ÚlenÚint)r   r	   r
   r   r   Úpad_colÚ	pad_indexZ
rule_equalÚsimple_tablesÚtabÚtxtÚoutr   rb   r   r   œ   s.    



"
zSummary.as_textc                 C   sZ   | j }| j}t||ƒ}dd„ |D ƒ}d |¡}dd„ | jD ƒ}d |¡}d ||g¡}|S )z$Generate HTML Summary Table
        c                 S   s   g | ]}|  ¡ ‘qS r   r   r2   r   r   r   r6   É   s     z#Summary.as_html.<locals>.<listcomp>r^   c                 S   s   g | ]}|  d d¡‘qS )r^   ú<br/>
)Úreplace)r3   Ústr   r   r   r6   Ì   s     rn   )r	   r
   re   rc   r   )r   r	   r
   rj   rk   Ztemp_txtrl   rm   r   r   r   r   Á   s    


zSummary.as_htmlr7   c                 C   s¦   | j }| j}| j}|dk	r(d| d }nd}d| d }t||ƒ}dd„ |D ƒ}d |¡}d	}| jrrt |d
|¡}d|||df}d |¡}d | j¡}	|d |	 }
|
S )zÉGenerate 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                 S   s   g | ]}|  ¡ ‘qS r   )Zas_latex_tabularr2   r   r   r   r6   è   s     z$Summary.as_latex.<locals>.<listcomp>z

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

\bigskip
)	r	   r
   r   re   rc   r   ÚreÚsubr   )r   Úlabelr	   r
   r   rj   rk   Z
to_replaceZnon_captionedrl   rm   r   r   r   r   Ó   s$    	


zSummary.as_latex)TTr   r    )r    r   )r.   r/   r   )NN)rR   r   NNN)r7   )rN   Ú
__module__Ú__qualname__r   r   r   r   r   r(   r-   rH   rJ   rQ   r\   r   r   r   r   r   r   r   r      s&     ÿ



    ÿ
%r   c                 C   sª   t | |ƒ}dd„ |D ƒ}dd„ |D ƒ}t|ƒ}g }g }tt|ƒƒD ]X}t| | jd d dƒ}	t|||  |	 ƒ}
| |
¡ || |	|
  }| || ¡ qB||t|ƒfS )zôCompare 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                 S   s   g | ]}|  ¡ ‘qS r   r   r2   r   r   r   r6     s     z#_measure_tables.<locals>.<listcomp>c                 S   s   g | ]}t | ¡ d  ƒ‘qS ©r   )rf   Ú
splitlinesr2   r   r   r   r6     s     r   )re   ÚmaxÚrangerf   rA   rg   r&   )r	   r
   rj   rk   ÚlengthZlen_maxZpad_sepri   ÚiZnseprG   Zlen_newr   r   r   rd   û   s    

rd   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)ZOLSZGLSZGLSARZWLSZRLMZNBinZGLMc                 C   s´  d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„ |d< dd„ |d< dd„ |d< dd„ |d< dd„ |d< | j rºdnd }d!d„ |d"| d# < d$d„ |d%| d# < d&d„ |d'< d(d„ |d)< d*d„ |d+< d,d„ |d-< d.d„ |d/< d0d„ |d1< d2d„ |d3< d4d„ |d5< d6d„ |d7< d8d„ |d9< d:d„ |d;< i }| ¡ D ]8\}}z|| ƒ||< W n tttfk
�rª   Y nX �qv|S )<z8
    Create a dict with information about the model
    c                  _   s   t j  ¡ }| d¡S )Nz%Y-%m-%d %H:%M)ÚdatetimeÚnowÚstrftime)ÚargsÚkwdsr~   r   r   r   Útime_now$  s    
zsummary_model.<locals>.time_nowc                 S   s
   | j jjS r   )rL   rM   rN   ©r4   r   r   r   r<   )  r=   zsummary_model.<locals>.<lambda>zModel:c                 S   s
   | j jjS r   )ÚfamilyZ__classrN   rƒ   r   r   r   r<   *  r=   zModel Family:c                 S   s   | j jjjS r   )r„   ÚlinkrM   rN   rƒ   r   r   r   r<   +  r=   zLink Function:c                 S   s   | j jS r   )rL   Úendog_namesrƒ   r   r   r   r<   ,  r=   rU   zDate:c                 S   s
   d| j  S ©Nz%#6d)Znobsrƒ   r   r   r   r<   .  r=   zNo. Observations:c                 S   s
   d| j  S r‡   )Zdf_modelrƒ   r   r   r   r<   /  r=   z	Df Model:c                 S   s
   d| j  S r‡   )Zdf_residrƒ   r   r   r   r<   0  r=   zDf Residuals:c                 S   s
   | j d S )NZ	converged©Zmle_retvalsrƒ   r   r   r   r<   1  r=   z
Converged:c                 S   s
   | j d S )NZ
iterationsrˆ   rƒ   r   r   r   r<   2  r=   zNo. Iterations:c                 S   s   | j S r   )Úmethodrƒ   r   r   r   r<   3  r=   zMethod:c                 S   s
   | j d S )NZnorm©Zfit_optionsrƒ   r   r   r   r<   4  r=   zNorm:c                 S   s
   | j d S )NZ	scale_estrŠ   rƒ   r   r   r   r<   5  r=   zScale Est.:c                 S   s
   | j d S )NZcovrŠ   rƒ   r   r   r   r<   6  r=   z
Cov. Type:r7   z (uncentered)c                 S   s
   d| j  S ©Nz%#8.3f)Úrsquaredrƒ   r   r   r   r<   9  r=   ú	R-squaredú:c                 S   s
   d| j  S r‹   )Úrsquared_adjrƒ   r   r   r   r<   :  r=   zAdj. R-squaredc                 S   s
   d| j  S r‹   )Z	prsquaredrƒ   r   r   r   r<   ;  r=   zPseudo R-squared:c                 S   s
   d| j  S ©Nz%8.4f)Zaicrƒ   r   r   r   r<   <  r=   zAIC:c                 S   s
   d| j  S r�   )Zbicrƒ   r   r   r   r<   =  r=   zBIC:c                 S   s
   d| j  S ©Nz%#8.5g)Zllfrƒ   r   r   r   r<   >  r=   zLog-Likelihood:c                 S   s
   d| j  S r‘   )Zllnullrƒ   r   r   r   r<   ?  r=   zLL-Null:c                 S   s
   d| j  S r‘   )Z
llr_pvaluerƒ   r   r   r   r<   @  r=   zLLR p-value:c                 S   s
   d| j  S r‘   )Zdeviancerƒ   r   r   r   r<   A  r=   z	Deviance:c                 S   s
   d| j  S ©Nz%#6.3g)Zpearson_chi2rƒ   r   r   r   r<   B  r=   zPearson chi2:c                 S   s
   d| j  S )Nz%#8.4g)Zfvaluerƒ   r   r   r   r<   C  r=   zF-statistic:c                 S   s
   d| j  S r’   )Zf_pvaluerƒ   r   r   r   r<   D  r=   zProb (F-statistic):c                 S   s
   d| j  S r‘   )Úscalerƒ   r   r   r   r<   E  r=   zScale:)Z
k_constantÚitemsÚAttributeErrorÚKeyErrorÚNotImplementedError)rP   r‚   r[   Zrsquared_typerm   ÚkeyÚfuncr   r   r   rW     sJ    
rW   rR   TFr   c              	   C   s  t | tƒr| \} }}}	}
}n"| j}| j}| j}	| j}
|  |¡}t |||	|
g¡j	}t 
||g¡}t |¡}|rždddddt|d ƒ td|d  ƒd g|_n.ddd	d
dt|d ƒ td|d  ƒd g|_|�sz| jjj|_W n  tk
�r   | jj|_Y nX n||_|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|ú[r.   r   ú]ÚzzP>|z|)rK   ÚtupleÚparamsÚbseÚtvaluesÚpvaluesÚconf_intr8   r+   ÚTr9   r)   r*   r   ÚcolumnsrL   rF   Zparam_namesr"   r•   Z
exog_names)rP   rY   rX   rS   rT   Zskip_headerr$   rŸ   r    r¡   r¢   r£   rF   r   r   r   rV   Q  s4    


 ÿ ÿrV   c           
         s¾  t | ƒ}|jdd… D ]}||  ‡ fdd„¡||< qd|jdd…df  d |jdd…df< |�r|jdd…df d	k }|j||jd
 f d |j||jd
 f< |jdd…df dk }|j||jd
 f d |j||jd
 f< |jdd…df dk }|j||jd
 f d |j||jd
 f< |jdd…dd…f }| ¡ }|�r t| dtjƒ}t| dtjƒ}t	 
||dœ¡}	|	 ¡  ¡ �r |	 ‡ fdd„¡}	t	j||	gd
d�}t	 |¡}t| jjƒg|_|S )z<Stack coefficients and standard errors in single column
    Nr.   c                    s   ˆ |  S r   r   rƒ   r5   r   r   r<   –  r=   z_col_params.<locals>.<lambda>ú(r   ú)é   gš™™™™™¹?r   Ú*rR   g{®Gáz„?rŒ   r�   ))r�   r7   )zR-squared Adj.r7   c                    s   ˆ |  S r   r   rƒ   r5   r   r   r<   ­  r=   )Zaxis)rV   r¥   ÚapplyÚilocÚlocÚstackÚgetattrr8   Únanr)   ÚSeriesZnotnullÚanyÚconcatr*   r   rL   r†   )
Úresultr$   ÚstarsÚ
include_r2ÚresÚcolÚidxrŒ   r�   Úr2r   r5   r   Ú_col_paramsŽ  s2    ((((ÿ
rº   c              	   C   sŒ   |dkri }g }g }|D ]T}t || tƒr,qz| || | ƒ¡ W n tk
r`   | d¡ Y nX | |¡ qtjt| jjƒ|i|d�}|S )z!Stack model info in a column
    Nr7   )r"   )	rK   Údictr&   r•   r)   r*   r   rL   r†   )r³   Ú	info_dictrm   r"   r|   r   r   r   Ú	_col_infoµ  s    r½   c                 C   sd   t t| ƒƒt | ƒkr| S ddlm} |tƒ}g }| D ]*}||  d7  < | |d ||  ¡ q4|S )Nr   )ÚdefaultdictÚIr_   )rf   ÚsetÚcollectionsr¾   r   r&   )Zlist_of_namesr¾   Zname_counterr#   Ú_namer   r   r   Ú_make_uniqueÊ  s    rÃ   r   c                    s’  t | tƒs| g} ‡ ‡‡fdd„| D ƒ}|r4t|ƒ}	ntdd„ |D ƒƒ}	tt|ƒƒD ]}
|	|
 g||
 _qRdd„ }t||ƒ}ˆ�r&|j d¡ 	¡ ‰t
 ˆ¡ ¡ }|j|dk j 	¡ ‰‡fdd„ˆD ƒ}‡fd	d„ˆD ƒ}|| ‰‡fd
d„|j d¡D ƒ}ˆ|7 ‰|�r|D ]}ˆ |¡ �q
|jˆ }g }|j d¡}td|jd dƒD ]\}
| ||
 ¡ |
d |jd k �r�||
 ||
d  k�r�| d¡ n| ||
d  ¡ �qH||_ˆ�rÆ‡fdd„| D ƒ}ndd„ | D ƒ}t|tdd„ |D ƒƒƒD ]\}}|g|_�qìdd„ }t||ƒ}t
 t ||g¡¡}|j|_t
 |j 	¡ |j 	¡  ¡|_|}| d¡}tƒ }d|_|j|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                    s   g | ]}t |ˆˆ ˆd �‘qS ))r´   r$   rµ   )rº   r2   )r$   rµ   r´   r   r   r6   ÿ  s   ÿÿzsummary_col.<locals>.<listcomp>c                 S   s   g | ]}|j d  ‘qS rw   ©r¥   r2   r   r   r   r6     s     c                 S   s   | j |dddd�S ©NÚouterT)ÚhowZright_indexZ
left_index©Úmerger:   r   r   r   Úmerg
  s    
ÿzsummary_col.<locals>.mergr   r.   c                    s   g | ]}|ˆ kr|‘qS r   r   r2   )Úvarnamesr   r   r6     s      c                    s   g | ]}|ˆ kr|‘qS r   r   r2   )Úregressor_orderr   r   r6     s      c                    s   g | ]}|ˆ kr|‘qS r   r   r2   )Ú	new_orderr   r   r6     s    ÿr   r7   c                    s$   g | ]}t |ˆ  |jjjˆ ¡ƒ‘qS r   )r½   ÚgetrL   rM   rN   r2   )r¼   r   r   r6   +  s   ÿÿc                 S   s   g | ]}t |t|d dƒƒ‘qS )Zdefault_model_infosN)r½   r®   r2   r   r   r   r6   .  s     c                 S   s   g | ]}|j d  ‘qS rw   rÄ   )r3   r'   r   r   r   r6   1  s     c                 S   s   | j |dddd�S rÅ   rÈ   r:   r   r   r   rÊ   4  s    
ÿTr/   )r#   r%   zStandard errors in parentheses.z* p<.1, ** p<.05, ***p<.01)rK   ÚlistrÃ   rz   rf   r¥   r   r"   Zget_level_valuesÚtolistr)   r°   Zvalue_countsr¬   ÚremoverA   r&   Úzipr*   r8   rB   ÚIndexZfillnar   r   r(   rJ   )rP   r$   Zmodel_namesr´   r¼   rÌ   Zdrop_omittedrµ   ÚcolsZcolnamesr|   rÊ   ZsummÚvcZorderedÚ	unorderedÚotherZuor¸   r"   r'   Únamer[   ÚdatZsmryr   )r$   rµ   r¼   rÍ   rÌ   r´   rË   r   Úsummary_col×  sp    %
ÿ


*
ÿÿ 



rÚ   c              	   C   s6   z||  }W n  t tfk
r,   t| ƒ}Y nX | ¡ S r   )Ú
ValueErrorÚ	TypeErrorr   Ústrip)Úelementr$   rm   r   r   r   r1   J  s
    r1   r    ú-c
                    s>  |   ¡ }
z|
 ‡ fdd„¡}
W n& tk
rD   |
 ‡ fdd„¡}
Y nX |r`dd„ |
j ¡ D ƒ}nd }|r‚‡fdd„|
j ¡ D ƒ}n2‡fdd„|
jd d …df D ƒ|
jd d …df< d }tt	 
|
¡||ttd	�}||jd
 d< ||jd
 d< ||jd d< ||jd d< ||jd d< ||jd d< dt|d ƒ |jd d< |S )Nc                    s
   t | ˆ ƒS r   r0   rƒ   r5   r   r   r<   W  r=   z$_df_to_simpletable.<locals>.<lambda>c                    s
   t | ˆ ƒS r   r0   rƒ   r5   r   r   r<   Y  r=   c                 S   s   g | ]}t |ƒ‘qS r   )r   r2   r   r   r   r6   [  s     z&_df_to_simpletable.<locals>.<listcomp>c                    s    g | ]}t |ƒtˆ ƒd   ‘qS ©r_   ©r   rg   r2   ©ri   r   r   r6   _  s     c                    s    g | ]}t |ƒtˆ ƒd   ‘qS rà   rá   r2   râ   r   r   r6   a  s   ÿr   )ÚheadersÚstubsZltx_fmtZtxt_fmtÚlatexZdata_alignsZheader_alignrl   Útable_dec_aboveÚtable_dec_belowÚheader_dec_belowr_   r   Zcolsep)ÚcopyÚmapr•   Zapplymapr¥   rÐ   r"   r«   r   r8   r+   r   r   Zoutput_formatsrg   )r'   r%   r$   r#   r"   ræ   rç   rè   rh   ri   rÙ   rã   rä   rp   r   )r$   ri   r   Ú_df_to_simpletableR  s4    
ÿ ÿrë   c                 C   s¢   g }|r|d d nd}|d kr.dgt | ƒ }|d krDdgt | ƒ }t| ƒD ]P\}}|| d }|| d }	|| d }
| t||
||	||| || d�¡ qL|S )Nr   r$   r   r"   r#   r%   )r%   r$   r#   r"   rh   ri   )rf   Ú	enumerater&   rë   )r	   r
   rh   ri   rj   r$   r|   Úvr"   r#   r%   r   r   r   re   p  s$    
 ü
re   )NNrR   TFr   )r   TF)N)r   r   FNr   FT)r   )	r    r   TTrß   Nrß   r   r   )NN)Zstatsmodels.compat.pythonr   r}   Ú	functoolsr   rr   r`   Únumpyr8   Zpandasr)   r,   r   Ztableformattingr   r   r   rd   rO   rW   rV   rº   r½   rÃ   rÚ   r1   rë   re   r   r   r   r   Ú<module>   sV    mú
2    ÿ
=
'
       þ
s
           þ
