
    'YHhW                         d dl mZ 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y)#    )FUTURE_STACK)lzipN)reduce   )SimpleTable)	fmt_latexfmt_txtc                   t    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y
)Summaryc                 J    g | _         g | _        g | _        d | _        d| _        y )NF)tablessettings	extra_txttitle_merge_latexselfs    S/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/iolib/summary2.py__init__zSummary.__init__   s&    
!    c                 "    | j                         S N)as_textr   s    r   __str__zSummary.__str__   s    ||~r   c                 X    t        t        |             dz   | j                         z   dz   S )Nz
"""
z
""")strtyper   r   s    r   __repr__zSummary.__repr__   s%    4:*T\\^;gEEr   c                 "    | j                         S )z$Display as HTML in IPython notebook.)as_htmlr   s    r   _repr_html_zSummary._repr_html_   s    ||~r   c                 "    | j                         S )z9Display as LaTeX when converting IPython notebook to PDF.)as_latexr   s    r   _repr_latex_zSummary._repr_latex_"   s    }}r   c                 ~    ||||d}| j                   j                  |       | j                  j                  |       y)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&   s:    $ #f$05B2X&r   c                 Z    t        j                  |      }| j                  |dd||       y)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)   tables        r   	add_arrayzSummary.add_array=   s.     U#Eu!-U 	 	<r   c                    |j                         D cg c]  }t        ||       }}|j                         D cg c]  }t        ||       }}t        j                  t        ||            }|j                  d   |z  dk7  rE||j                  d   |z  z
  }	t        j                  |t        j                  |	ddggz        g      }t        j                  ||      }t        d |      }| j                  ||       yc c}w c c}w )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
        r    c                 0    t        j                  | |g      S r   )nphstackxys     r   <lambda>z"Summary.add_dict.<locals>.<lambda>f   s    299aV#4 r   r*   N)keys
_formattervaluesr7   r1   r   shapevstacksplitr   r3   )
r   dncolsr*   r)   r:   r>   valsdatapads
             r   add_dictzSummary.add_dictM   s      67VVX>
1l+>>56XXZ@
1l+@@xxT4()::a=5 A%4::a=501C99dBHHSRH:-=$>?@Dxxe$4d;t5) ?@s
   C?Dc                 :    | j                   j                  |       y)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_texti   s     	f%r   Nc                     t        |t              r|| _        y|<|j                  j                  j
                  }|t        v r	t        |   }d|z   | _        yd| _        y)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: r5   )
isinstancer   r   model	__class____name___model_types)r   r   resultsrO   s       r   	add_titlezSummary.add_titleo   sU     eS!DJ"//88L((/E(50

r   c                     t        |||j                        }t        |      }|||_        |||d<   | j	                  |d       | j                  ||       | j                  ||       y)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:lr=   )r)   )r   rS   )summary_paramsrW   summary_modelr'   rI   r-   rT   )	r   rS   rV   r)   r   xnameynameparaminfos	            r   add_basezSummary.add_base   sn    & we7==IW%EK*/D&'d#&E5UG4r   c                    | j                   }| j                  }| j                  }| j                  }t	        ||      \  }}}|dz  }t        ||||      }	|	D 
cg c]  }
|
j                          }}
dj                  |      }|j                  d      }||d<   |j                  |       dj                  |      }|4|}t        |      |k  r&dt        |dz  t        |      dz  z
        z  |z   }nd}|D 
cg c]  }
t        j                  |
|       }}
|D 
cg c]  }
dj                  |
       }}
dj                  |      }dj                  |||g      }|S c c}
w c c}
w c c}
w )z%Generate ASCII Summary Table
        =
r       r5   )r   r   r   r   _measure_tables_simple_tablesr   joinrC   r+   leninttextwrapwrap)r   r   r   r   r   pad_col	pad_indexwidest
rule_equalsimple_tablesr:   tabtxtouts                 r   r   zSummary.as_text   sW    ==

NN	%4VX%F"Fc\
&vx)L$12qqyy{22iiniioA

:iinE5zF"c&1*s5zA~"=>>FE1:;Ax}}Q';;%()tyy|))iiniiS)*
+ 3 <)s   E6EE$c                 X   | j                   }| j                  }t        ||      }|D cg c]  }|j                          }}dj	                  |      }| j
                  D cg c]  }|j                  dd       }}dj	                  |      }dj	                  ||g      }	|	S c c}w c c}w )z$Generate HTML Summary Table
        rc   z<br/>
)r   r   rg   r    rh   r   replace)
r   r   r   rq   r:   rr   sttemp_txtrs   rt   s
             r   r    zSummary.as_html   s     ==&vx8$12qqyy{22iin9=H2BJJtY/HHnnX&nnc3Z(
 3 Is   B"!B'c                    | j                   }| j                  }| j                  }|	d|z   dz   }nd}d|z   dz   }t        ||      }|D cg c]  }|j	                          }}dj                  |      }d}| j                  rt        j                  |d|      }d|||d	f}	d
j                  |	      }	dj                  | j                        }
|	dz   |
z   }|S c c}w )zGenerate LaTeX Summary Table

        Parameters
        ----------
        label : str
            Label of the summary table that can be referenced
            in a latex document (optional)
        z	\caption{}z
\caption{}z\label{z

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

\bigskip
)
r   r   r   rg   as_latex_tabularrh   r   resubr   )r   labelr   r   r   rq   r:   rr   
to_replacenon_captionedrs   rt   s               r   r#   zSummary.as_latex   s     ==

 5(3.E!EU"S(&vx8-:;q!!#;;kk#A
 &&^S9C(%^K		-0""4>>2o-3
! <s   
C)TT%.4fr)r   r   )re   rY   r   NN)皙?r   NNN)r5   )rQ   
__module____qualname__r   r   r   r!   r$   r-   r3   rI   rL   rT   r`   r   r    r#    r   r   r   r      s^    "F @F'.< *8& " HL#'5:#J$%r   r   c                    t        | |      }|D cg c]  }|j                          }}|D cg c]  }t        |j                         d           }}t	        |      }g }g }t        t        |            D ]e  }	t	        | |	   j                  d   dz
  d      }
t        |||	   z
  |
z        }|j                  |       ||	   |
|z  z   }|j                  ||z
         g ||t	        |      fS c c}w c c}w )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.
    r   r   )	rg   r   ri   
splitlinesmaxrangerA   rj   r+   )r   r   rq   r:   rr   lengthlen_maxpad_seprn   inseprH   len_news                r   rf   rf      s     #684M -
.1199;
.C
..12c!,,.#$2F2&kGGI3s8_ ,6!9??1%)1-7VAY&$./s)dSj(7*+, Is6{** /2s
   C,#C1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 }|j                         D ]  \  }}	  ||       ||<    |S # t        t        t        f$ r Y ,w xY w):z8
    Create a dict with information about the model
    c                  `    t         j                   j                         }|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                 B    | j                   j                  j                  S r   )rO   rP   rQ   r:   s    r   r<   zsummary_model.<locals>.<lambda>*  s    qww0099 r   zModel:c                 B    | j                   j                  j                  S r   )family__classrQ   r   s    r   r<   zsummary_model.<locals>.<lambda>+  s    ahh&6&6&?&? r   zModel Family:c                 V    | j                   j                  j                  j                  S r   )r   linkrP   rQ   r   s    r   r<   zsummary_model.<locals>.<lambda>,  s    qxx}}'>'>'G'G r   zLink Function:c                 .    | j                   j                  S r   )rO   endog_namesr   s    r   r<   zsummary_model.<locals>.<lambda>-  s    AGG,?,? r   rX   zDate:c                      d| j                   z  S Nz%#6d)nobsr   s    r   r<   zsummary_model.<locals>.<lambda>/  s    &166/ r   zNo. Observations:c                      d| j                   z  S r   )df_modelr   s    r   r<   zsummary_model.<locals>.<lambda>0  s    &1::"5 r   z	Df Model:c                      d| j                   z  S r   )df_residr   s    r   r<   zsummary_model.<locals>.<lambda>1  s    fqzz&9 r   zDf Residuals:c                      | j                   d   S )N	convergedmle_retvalsr   s    r   r<   zsummary_model.<locals>.<lambda>2  s    1==#= r   z
Converged:c                      | j                   d   S )N
iterationsr   r   s    r   r<   zsummary_model.<locals>.<lambda>3  s    l(C r   zNo. Iterations:c                     | j                   S r   )methodr   s    r   r<   zsummary_model.<locals>.<lambda>4  s
     r   zMethod:c                      | j                   d   S )Nnormfit_optionsr   s    r   r<   zsummary_model.<locals>.<lambda>5  s    ammF3 r   zNorm:c                      | j                   d   S )N	scale_estr   r   s    r   r<   zsummary_model.<locals>.<lambda>6  s    AMM+$> r   zScale Est.:c                      | j                   d   S )Ncovr   r   s    r   r<   zsummary_model.<locals>.<lambda>7  s    1==#7 r   z
Cov. Type:r5   z (uncentered)c                      d| j                   z  S Nz%#8.3f)rsquaredr   s    r   r<   zsummary_model.<locals>.<lambda>:  s    1::8M r   	R-squared:c                      d| j                   z  S r   )rsquared_adjr   s    r   r<   zsummary_model.<locals>.<lambda>;  s    X=V r   zAdj. R-squaredc                      d| j                   z  S r   )	prsquaredr   s    r   r<   zsummary_model.<locals>.<lambda><  s    (Q[[*@ r   zPseudo R-squared:c                      d| j                   z  S Nz%8.4f)aicr   s    r   r<   zsummary_model.<locals>.<lambda>=      Wquu_ r   zAIC:c                      d| j                   z  S r   )bicr   s    r   r<   zsummary_model.<locals>.<lambda>>  r   r   zBIC:c                      d| j                   z  S Nz%#8.5g)llfr   s    r   r<   zsummary_model.<locals>.<lambda>?  s    155(8 r   zLog-Likelihood:c                      d| j                   z  S r   )llnullr   s    r   r<   zsummary_model.<locals>.<lambda>@  s    AHH!4 r   zLL-Null:c                      d| j                   z  S r   )
llr_pvaluer   s    r   r<   zsummary_model.<locals>.<lambda>A  s    X%< r   zLLR p-value:c                      d| j                   z  S r   )deviancer   s    r   r<   zsummary_model.<locals>.<lambda>B  s    (QZZ"7 r   z	Deviance:c                      d| j                   z  S Nz%#6.3g)pearson_chi2r   s    r   r<   zsummary_model.<locals>.<lambda>C  s    h&? r   zPearson chi2:c                      d| j                   z  S )Nz%#8.4g)fvaluer   s    r   r<   zsummary_model.<locals>.<lambda>D  s    X%8 r   zF-statistic:c                      d| j                   z  S r   )f_pvaluer   s    r   r<   zsummary_model.<locals>.<lambda>E  s    Hqzz,A r   zProb (F-statistic):c                      d| j                   z  S r   )scaler   s    r   r<   zsummary_model.<locals>.<lambda>F  s    x!''1 r   zScale:)
k_constantitemsAttributeErrorKeyErrorNotImplementedError)rS   r   r_   rsquared_typert   keyfuncs          r   r[   r[      s   
. D9DN?DGD	"?D	DM 9D	5D9D=DCD	(DO3DM>D7D!,,B/M.MD}	$s	*+3VD	M	)C	/0 @D	,DL,DL8D	4D<D7D?D8D"AD	1DN
CZZ\ 	T	G}CH J	 *=> 	 	s   C++DDc           
         t        | t              r
| \  } }}}	}
}nA| j                  }| j                  }| j                  }	| j
                  }
| j                  |      }t        j                  |||	|
g      j                  }t        j                  ||g      }t        j                  |      }|r/dddddt        |dz        z   t        d|dz  z
        dz   g|_        n.ddd	d
dt        |dz        z   t        d|dz  z
        dz   g|_        |s(	 | j                  j                   j"                  |_        |S ||_        |S # t&        $ r | j                  j(                  |_        Y |S w xY w)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|[re   r   ]zzP>|z|)rN   tupleparamsbsetvaluespvaluesconf_intr7   r1   Tr8   r/   r0   r   columnsrO   rG   param_namesr'   r   
exog_names)rS   r]   r\   rV   rW   skip_headerr)   r   r   r   r   r   rG   s                r   rZ   rZ   R  sd   : '5!;B8gwkk////##E*88VS'73466D99dH%&D<<DS'c%!)n,c!eai-.@3.FH  S'c%!)n,c!eai-.@3.FH 	2 ++77DJ K 
K  	2 11DJ K	2s   %D= =$E%$E%c                    t        |       }|j                  dd D ]  }||   j                  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   } |j
                  di t        }|rt        | dt        j                        }t        | dt        j                        }t        j                  ||d      }	|	j                         j                         r-|	j                  fd      }	t        j                  ||	gd	      }t        j                  |      }t!        | j"                  j$                        g|_        |S )z<Stack coefficients and standard errors in single column
    Nre   c                     | z  S r   r   r:   r)   s    r   r<   z_col_params.<locals>.<lambda>  s    L1,< r   (r   )   g?r   *r   g{Gz?r   r   )r   r5   )zR-squared Adj.r5   c                     | z  S r   r   r   s    r   r<   z_col_params.<locals>.<lambda>  s    L1$4 r   )axisr   )rZ   r   applyiloclocstackr   getattrr7   nanr/   Seriesnotnullanyconcatr0   r   rO   r   )
resultr)   stars
include_r2rescolidxr   r   r2s
    `        r   _col_paramsr    s   
 
 C{{2A >s8>>"<=C> 388AqD>)C/CHHQTNhhq!tnr!'*wwsCKKN/B'Cc'IS[[^#$hhq!tns"'*wwsCKKN/B'Cc'IS[[^#$hhq!tns"'*wwsCKKN/B'Cc'IS[[^#$
((1bqb5/C
#))
#l
#C 6:rvv6v~rvv>YY80<> ? ::<45B))S"IA.C
,,s
Cv||//01CKJr   c                 P   |i }g }g }|D ]B  }t        ||   t              r	 |j                   ||   |              |j                  |       D t	        j
                  t        | j                  j                        |i|      }|S # t        $ r |j                  d       Y gw xY w)z!Stack model info in a column
    r5   )r'   )	rN   dictr+   r   r/   r0   r   rO   r   )r  	info_dictrt   r'   r   s        r   	_col_infor    s     	
CE ilD)	JJ|y|F+, 	Q ,,FLL445s;5
ICJ	  	JJrN	s   BB%$B%c                     t        t        |             t        |       k(  r| S ddlm}  |t              }g }| D ])  }||xx   dz  cc<   |j                  |dz   ||   z          + |S )Nr   )defaultdictIrd   )ri   setcollectionsr  r   r+   )list_of_namesr  name_counterr(   _names        r   _make_uniquer"    sq    
3}#m"44's#LF 9Us"eckL$7789 Mr   c                 6	   t        | t              s| g} | D cg c]  }t        ||||       }	}|rt        |      }
n&t        |	D cg c]  }|j                  d    c}      }
t        t        |	            D ]  }|
|   g|	|   _         d }t        |	d   j                        }|	dd D ])  }|j                  D ]  }||vs|j                  |        + dD ]3  }||v s|j                  |       |j                  t        |      |       5 t        ||	      }|j                  |      }|r|j                  j                  d      j                         }t        j                   |      j#                         }|j$                  |dk(     j                  j                         }|D cg c]	  }||v s| }}|D cg c]	  }||vs| }}||z   }|j                  j                  d      D cg c]  }||vr|
 }}||z  }|r|D ]  }|j                  |        |j                  |d      }g }|j                  j                  d      }t        d|j&                  d   d      D ]b  }|j                  ||          |dz   |j&                  d   k  r ||   ||dz      k(  r|j                  d	       L|j                  ||dz             d ||_        |rH| D cg c]<  }t)        ||j+                  |j,                  j.                  j0                  |            > }	}n$| D cg c]  }t)        |t3        |d
d             }	}t5        |	t        |	D cg c]  }|j                  d    c}            D ]  \  }}|g|_         t        ||	      }t        j6                  t9        j:                  ||g            }|j                  |_        t        j<                  |j                  j                         |j                  j                         z         |_        |}|j?                  d	      }tA               }d|_!        |jE                  |dd       |jG                  d       |r|jG                  d       |S c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w )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.
    )r  r)   r  r   c                 ,    | j                  |ddd      S )NouterT)howright_index
left_index)merger9   s     r   mergzsummary_col.<locals>.merg  s    wwqg4DwIIr   r   Nr  re   )levelr5   default_model_infosTrY   )r(   r*   zStandard errors in parentheses.z* p<.1, ** p<.05, ***p<.01)$rN   listr  r"  r   r   ri   r'   r+   removeinsertr   reindexget_level_valuestolistr/   r
  value_countsr  rA   r  getrO   rP   rQ   r  zipr0   r7   rB   Indexfillnar   r   r-   rL   )rS   r)   model_namesr  r  regressor_orderdrop_omittedr  r:   colscolnamesr   r*  r'   r  r   specialsummvarnamesvcordered	unordered	new_orderotheruor  r,   namer_   datsmrys                                  r   summary_colrI    sx   J gt$) 9@A34 \#-/ AD A ,t <!1 <=3t9 (#A;-Q(J aEABx "99 	"C%S!	"" ? .eLL!LLUW-.
 $D<<D::..q188:YYx --/66"'?((//1-?h1?? (E1A_,DQE	Ei'	 JJ77: (qY&  ( (U	 %  $%||IQ|/
CJJ''*E1ekk!na( %

58EU[[^#qU1q5\)AJJrNJJuQU|$% DJ @GI;< !Y]]177+<+<+E+E+46 7 I I !	!WQ(=tDE   lD+IbBJJqM+IJK DV
 $D
,,ryy$.
/C,,CK**,tzz/@/@/BBCCID;;r?D9DDKKTK-MM3423K_A !=2 @E((I ,Js<   Q3Q8)	Q=3Q==	RR/RAR!RRc                     	 || z  }|j                         S # t         t        f$ r t        |       }Y |j                         S w xY wr   )
ValueError	TypeErrorr   strip)elementr)   rt   s      r   r?   r?   R  sJ    W$ 99; 	" 'l99;s    AAc
                    | j                         }
	 |
j                  fd      }
|r1|
j                  j                         D cg c]  }t        |       }}nd }|r@|
j                  j                         D cg c]  }t        |      t        |	      dz  z    }}nL|
j                  d d df   D cg c]  }t        |      t        |	      dz  z    c}|
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 # t        $ r |
j                  fd      }
Y w xY wc c}w c c}w c c}w )Nc                     t        |       S r   r?   r   s    r   r<   z$_df_to_simpletable.<locals>.<lambda>_  s    
1l ; r   c                     t        |       S r   rQ  r   s    r   r<   z$_df_to_simpletable.<locals>.<lambda>a  s    Z<%@ r   rd   r   )headersstubsltx_fmttxt_fmtlatexdata_alignsheader_alignrs   table_dec_abovetable_dec_belowheader_dec_belowr   colsep)copymapr   applymapr   r2  r   r'   rj   r  r   r7   r1   r   r	   output_formats)r,   r*   r)   r(   r'   rZ  r[  r\  rm   rn   rG  r:   rS  rT  rw   s     `            r   _df_to_simpletablerb  Z  s    '')CBgg;< #&;;#5#5#78a3q6888;		8H8H8JK1Q#i.3..KK $'88AqD>3 a&3y>C#77 3A	RXXc]G5&
9B05Bg}-16Bg~..3Be]+2ABe./2ABe./3CBe/0),s7Q;/?)?BeX&I+  Bll@AB 9 L3s#   F$ G:!G3!G$GGc                 
   g }|r|d   d   nd}|dgt        |       z  }|dgt        |       z  }t        |       D ]D  \  }}||   d   }||   d   }	||   d   }
|j                  t        ||
||	|||   ||                F |S )Nr   r)   r   r'   r(   r*   )r*   r)   r(   r'   rm   rn   )ri   	enumerater+   rb  )r   r   rm   rn   rq   r)   r   vr'   r(   r*   s              r   rg   rg   x  s    M2:8A;~.L#F#C#f+%	&! I1G$!X&G$/=I7=U8?
:CA,	H 	I	I r   )NNr   TFr   )r   TFr   )r   r   FNr   FT)r   )	r   r   TT-Nrf  r   r   r   )statsmodels.compat.pandasr   statsmodels.compat.pythonr   r   	functoolsr   r|   rk   numpyr7   pandasr/   r2   r   tableformattingr   r	   r   rf   rR   r[   rZ   r  r  r"  rI  r?   rb  rg   r   r   r   <module>rm     s    2 *   	     /i iX+4 02?/,11/d FJ399z$N*
 EJAFwt CGHLBC<r   