
     j!                    .   d dl mZ d dlmZmZmZ d dlZd dlZd dl	m
Z
mZ d dlmZ d dlmZ d dlmZmZ d dlmZ erd d	lmZ d d
lmZ e	 d%ddd&d            Zeddd'd            Ze	 d%dddd(d            Zedddd)d             Z	 d*ed!dd+d$ZdS ),    )annotations)TYPE_CHECKINGLiteraloverloadN)libmissing)find_stack_levelmaybe_box_native)BaseMaskedDtypeExtensionDtype)common)MutableMappingT)	DataFrame.)indexdfr   orient<Literal['dict', 'list', 'series', 'split', 'tight', 'index']into'type[MutableMappingT] | MutableMappingTr   boolreturnr   c                   d S N r   r   r   r   s       oC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pandas/core/methods/to_dict.pyto_dictr       	     C    Literal['records']list[MutableMappingT]c                   d S r   r   r   s       r   r   r   +   r   r    )r   r   
type[dict]dictc                   d S r   r   r   s       r   r   r   6   r   r    
list[dict]c                   d S r   r   r   s       r   r   r   A   r   r    TGLiteral['dict', 'list', 'series', 'split', 'tight', 'records', 'index']'MutableMappingT | list[MutableMappingT]c          
     	     j         j        s(t          j        dt          t                                 t          j                  |                                }|s|dvrt          d          |dk    r' d  
                                D                       S d t           j        j                  D             }d t           j        j                  D             t          |          t           j                  k    }|d	k    r) fd
 
                                D                       S |dk    rFt          |           fdt           
                                          D                       S |dk    r_                     ||          } |rd j                                        ffndd j                                         fd|ffz             S |dk    r                     ||          } |rd j                                        ffndd j                                         fdd                      dd          D             ffz   |rdt)           j        j                  ffndz   dt)           j         j                  ffz             S |dk    rŉ j                                         |r1fd                     dd          D             }fd|D             S fd                     dd          D             }|rQt          |          fdt           j                   D             }|D ]}	|D ]}
t-          |	|
                   |	|
<    |S |dk    r j        j        st          d           j                                         |r+  fd                     d           D                       S |rht          |          fd!t/          t           j                             D              fd"                     d           D                       S   fd#                     d           D                       S t          d$| d%          )&a  
    Convert the DataFrame to a dictionary.

    The type of the key-value pairs can be customized with the parameters
    (see below).

    Parameters
    ----------
    orient : str {'dict', 'list', 'series', 'split', 'tight', 'records', 'index'}
        Determines the type of the values of the dictionary.

        - 'dict' (default) : dict like {column -> {index -> value}}
        - 'list' : dict like {column -> [values]}
        - 'series' : dict like {column -> Series(values)}
        - 'split' : dict like
          {'index' -> [index], 'columns' -> [columns], 'data' -> [values]}
        - 'tight' : dict like
          {'index' -> [index], 'columns' -> [columns], 'data' -> [values],
          'index_names' -> [index.names], 'column_names' -> [column.names]}
        - 'records' : list like
          [{column -> value}, ... , {column -> value}]
        - 'index' : dict like {index -> {column -> value}}

        .. versionadded:: 1.4.0
            'tight' as an allowed value for the ``orient`` argument

    into : class, default dict
        The collections.abc.MutableMapping subclass used for all Mappings
        in the return value.  Can be the actual class or an empty
        instance of the mapping type you want.  If you want a
        collections.defaultdict, you must pass it initialized.

    index : bool, default True
        Whether to include the index item (and index_names item if `orient`
        is 'tight') in the returned dictionary. Can only be ``False``
        when `orient` is 'split' or 'tight'.

        .. versionadded:: 2.0.0

    Returns
    -------
    dict, list or collections.abc.Mapping
        Return a collections.abc.MutableMapping object representing the
        DataFrame. The resulting transformation depends on the `orient` parameter.
    z?DataFrame columns are not unique, some columns will be omitted.)
stacklevel)splittightz?'index=False' is only valid when 'orient' is 'split' or 'tight'seriesc              3  $   K   | ]\  }}||fV  d S r   r   .0kvs      r   	<genexpr>zto_dict.<locals>.<genexpr>   s*      44Aq!f444444r    c                |    g | ]9\  }}|t          j        t                    k    st          |t                    7|:S r   )npdtypeobject
isinstancer   r2   i	col_dtypes      r   
<listcomp>zto_dict.<locals>.<listcomp>   sU       Ay((( -7y.,Q,Q	  r    c                n    g | ]2\  }}t          |t                    st          j        nt          j        3S r   )r:   r   r   
no_default
libmissingNAr;   s      r   r>   zto_dict.<locals>.<listcomp>   sC       Ay )ODDW*-  r    r%   c              3  N   K   | ]\  }}||                                fV   dS ))r   N)r   )r2   r3   r4   r   s      r   r5   zto_dict.<locals>.<genexpr>   s:      GGDAqq!)))../GGGGGGr    listc              3    K   | ]\  }\  }}||v r<t          t          t          |                    |                                        n3t          t          t          |                                                    fV  dS ))na_valueN)rD   mapr   to_numpy)r2   r<   r3   r4   box_na_valuesobject_dtype_indices_as_sets       r   r5   zto_dict.<locals>.<genexpr>   s       
 
 6Aq 33?S)1::}Q?O:+P+PQQRRR#.

==>>	
 
 
 
 
 
r    r-   r   r   columnsdatar.   c                R    g | ]$}t          t          t          |                    %S r   )rD   rG   r   )r2   ts     r   r>   zto_dict.<locals>.<listcomp>   s;        S!115566  r    FN)r   nameindex_namescolumn_namesrecordsc              3  R   K   | ]!}t          t          |                    V  "d S r   )r%   zip)r2   rowrK   s     r   r5   zto_dict.<locals>.<genexpr>   sF        ,/S#&&''     r    c                ^    g | ])} d  |                                 D                       *S )c              3  >   K   | ]\  }}|t          |          fV  d S r   r
   r1   s      r   r5   z%to_dict.<locals>.<listcomp>.<genexpr>   s4      HHDAq+A../HHHHHHr    )items)r2   rU   into_cs     r   r>   zto_dict.<locals>.<listcomp>   sG       MPHHCIIKKHHHHH  r    c                B    g | ]} t          |                    S r   )rT   )r2   rN   rK   rY   s     r   r>   zto_dict.<locals>.<listcomp>   s8       ,-s7A''  r    c                "    h | ]\  }}|v 	|S r   r   )r2   r<   colrJ   s      r   	<setcomp>zto_dict.<locals>.<setcomp>   s9     % % %377%% % %r    z2DataFrame index must be unique for orient='index'.c              3     K   | ]I}|d          t          t          j        t          t          |dd                                       fV  JdS r      N)r%   rT   rK   rG   r   r2   rN   r   s     r   r5   zto_dict.<locals>.<genexpr>   sg         1tC
C0@!ABB%,H,HIIJJK     r    )rO   c                    g | ]}|v S r   r   )r2   r<   rJ   s     r   r>   zto_dict.<locals>.<listcomp>   s,     ( ( (5600( ( (r    c              3  p   K   | ]0}|d          fdt          |dd                   D             fV  1dS )r   c                V    i | ]%\  }}|         |         rt          |          n|&S r   r
   )r2   r<   r4   rK   is_object_dtype_by_indexs      r   
<dictcomp>z%to_dict.<locals>.<genexpr>.<dictcomp>  sQ        !Aq  
3A6%$4Q$7$7$7  r    r`   N)	enumerate)r2   rN   rK   re   s     r   r5   zto_dict.<locals>.<genexpr>   s          aD     %.ae$4$4	       r    c           
   3  |   K   | ]6}|d          t          t          j        |dd                             fV  7dS r_   )r%   rT   rK   ra   s     r   r5   zto_dict.<locals>.<genexpr>  sY        9:1tC
AabbE22334     r    zorient 'z' not understood)rK   	is_uniquewarningswarnUserWarningr	   comstandardize_mappinglower
ValueErrorrX   rg   dtypesvalueslenset(_create_data_for_split_and_tight_to_dictr   tolist
itertuplesrD   namesr   range)r   r   r   r   box_native_indicesare_all_object_dtype_colsrL   rowsobject_dtype_colsrU   r\   rI   rK   rY   re   rJ   s   ` `        @@@@@r   r   r   N   sX   l : 
M'))	
 	
 	
 	
 $T**F
 \\^^F 
V#55 
M
 
 	
  5v44444444 %bi&677  
 %bi&677  M !$$6 7 73ry>> I j>vGGGGBHHJJGGGGGG	6	 g>034F0G0G#v 
 
 
 
 
 'rxxzz22
 
 
 
 
 	
 
7	 [>::%'9
 
 v05=w))*,,2BJ--//0
 
 	
 
7	 N>::%'9
 
 v05=w))*,,2BJ--//0 !#U!F!F  	
 <AHRX^ 4 4577bJ RZ%5 6 679:
 
 	
  
9	 9>*##%%$ 	   35==uSW=3X3X  D   TX       13UQU1V1V  D " 	>.12D.E.E+% % % %"+BJ"7"7% % %!
   > >C0 > >#3CH#=#=C>K	7	  >x! 	SQRRR*##%%$ 	6    D11        	*-.@*A*A'( ( ( (:?BJ:P:P( ( ($ 6      D11      6    >@mmQUm>V>V     
 <F<<<===r    ).)
r   r   r   r   r   r   r   r   r   r   )
r   r   r   r!   r   r   r   r   r   r"   )
r   r   r   r   r   r$   r   r   r   r%   )
r   r   r   r!   r   r$   r   r   r   r'   )r%   )
r   r   r   r)   r   r   r   r   r   r*   )
__future__r   typingr   r   r   rj   numpyr7   pandas._libsr   r   rA   pandas.util._exceptionsr	   pandas.core.dtypes.castr   pandas.core.dtypes.dtypesr   r   pandas.corer   rm   pandas._typingr   pandasr   r   r%   r   r    r   <module>r      s3   " " " " " "         
             5 4 4 4 4 4 4 4 4 4 4 4       
 & % % % % % !......       
 LO
      
 
      
 
 LO      
 

      
  		B> 59B> B> B> B> B> B> B> B>r    