
    >h1                     t    S r SSKJr  SSKrSSKrSS jrS rS r	S r
SS jrS	 rS
 rS rS rS rS rS rg)z7
Compatibility tools for various data structure inputs
    )NP_LT_2Nc                 `   SSK JnJn  [        U R                  X#45      (       d  [        S5      eU R                  R                  b  U R                  R                  nO [        R                  " U R                  5      nUR                  U5      (       d  [        SR                  UU5      5      eg )Nr   )DatetimeIndexPeriodIndexz0The index must be a DatetimeIndex or PeriodIndexzExpected frequency {}. Got {})pandasr   r   
isinstanceindex
ValueErrorfreqfreqstrpd
infer_freq
startswithformat)xr   r   r   inferred_freqs        iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/tools/data.py_check_period_indexr   
   s    1agg;<<KLLww||agg.##D))8??@MO P 	P *    c                 6    [        U [        R                  5      $ N)r   r   	DataFrameobjs    r   is_data_framer      s    c2<<((r   c                 $    SSK Jn  [        X5      $ )Nr   )DesignMatrix)patsyr   r   )r   r   s     r   is_design_matrixr      s    "c((r   c                 t    [        U [        R                  5      =(       a    U R                  R                  S L$ r   )r   npndarraydtypenamesr   s    r   _is_structured_ndarrayr%   !   s%    c2::&F399??$+FFr   c                    [        U [        R                  5      (       aE  [        R                  " U 5      nUc+  [	        UR
                  S   5       Vs/ s H  nSU-  PM
     nnOp[        U 5      (       a5  U R                  5       n U R                  nU R                  nU R                  nO+[        SR                  [        U 5      R                  S95      e[        U[        5      (       d  [        U5      n[!        U5      UR
                  S   :w  a  [#        S5      eUb#  [!        U5      [!        U5      :w  a  [#        S5      eX1U4$ s  snf )a  
Convert passed data structure to form required by estimation classes

Parameters
----------
data : array_like
colnames : sequence or None
    May be part of data structure
rownames : sequence or None

Returns
-------
(values, colnames, rownames) : (homogeneous ndarray, list)
   zY_%dzCannot handle input type {typ})typz;length of colnames does not match number of columns in dataz8length of rownames does not match number of rows in data)r   r!   r"   asarrayrangeshaper   dropnavaluescolumnsr	   	TypeErrorr   type__name__listlenr
   )datacolnamesrownamesr-   is        r   interpret_datar8   %   s$    $

##D!,1&,,q/,BC,Bq
,BHC	t		{{}<<::8DJ$7$78: 	: h%%> 8}Q' . / 	/ HV < + , 	, X%%/ Ds   Ec                     U R                  [        [        U R                  R                  5      44[
        R                  S9$ )N)r0   )viewfloatr3   r#   r$   r!   r"   )arrs    r   struct_to_ndarrayr=   R   s.    88US1342::8FFr   c                     [        U 5      [        R                  L =(       a&    [        U5      [        R                  L =(       d    US L $ r   )r0   r!   r"   endogexogs     r   _is_using_ndarray_typerB   V   s5    K2::% 7$Z2::%58r   c                     [        U [        R                  5      =(       a%    [        U[        R                  5      =(       d    US L $ r   )r   r!   r"   r?   s     r   _is_using_ndarrayrD   [   s1    ubjj) ;bjj)9TT\<r   c                 H    SSK Jn  [        X5      =(       d    [        X5      $ )Nr   )data_klasses)statsmodels.compat.pandasrF   r   )r@   rA   klassess      r   _is_using_pandasrI   `   s    Au&C*T*CDr   c                 l     [         R                  " U 5      n [         R                  " U5      ng!    g= f)NTF)r!   r)   r?   s     r   _is_array_likerK   e   s0    

5!zz$s   ,/ 3c                 R    [        U 5      =(       a    [        U5      =(       d    US L $ r   )r   r?   s     r   _is_using_patsyrM   n   s%    U# 5d#3tt|6r   c                     [         (       a$  [        U [        R                  R                  5      $ [        U [        R
                  R                  5      $ )z$
Returns true if data is a recarray
)r   r   r!   corerecarrayrec)r4   s    r   _is_recarrayrR   t   s5     w$ 0 011$00r   )M)NN)__doc__statsmodels.compat.numpyr   numpyr!   r   r   r   r   r   r%   r8   r=   rB   rD   rI   rK   rM   rR    r   r   <module>rX      sV    -  P))
G*&ZG8
<
E
61r   