zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
U
¬ý°dÎã@s‚ddlmZddlmZddlZddlmZddlmZddl    m
Z
m Z ddl m Z ddlmZd    ed
fd d d dddœdd„ZdS)é)Ú annotations)ÚLiteralN)Úfind_stack_level©Úmaybe_box_native)Úis_extension_array_dtypeÚis_object_dtype)Ú    DataFrame)ÚcommonÚdictTr    zILiteral[('dict', 'list', 'series', 'split', 'tight', 'records', 'index')]z
type[dict]Úboolzdict | list[dict])ÚdfÚorientÚintoÚindexÚreturnc     s.ˆjjstjdttƒdt ˆ¡‰| ¡}|s@|dkr@t    dƒ‚|dkr^ˆdd„ˆ 
¡DƒƒSdd    „t ˆj j ƒDƒ}t|ƒtˆj ƒk}|d
kr¨ˆ‡fd d„ˆ 
¡DƒƒS|d krÖt|ƒ‰ˆ‡fd d„t ˆ 
¡ƒDƒƒS|dkr ˆ ||¡}ˆ|rdˆj ¡ffnddˆj ¡fd|ffƒS|dkr¬ˆ ||¡}ˆ|rNdˆj ¡ffnddˆj ¡fddd    „ˆjdddDƒff|r’dtˆjjƒffnddtˆjjƒffƒS|dkrfˆj ¡‰|rô‡fdd„ˆjdddDƒ}‡fdd    „|DƒS‡‡fdd    „ˆjdddDƒ}|r`t|ƒ‰‡fdd„t ˆjƒDƒ}|D]"}    |D]}
t|    |
ƒ|    |
<qDq<|SnÄ|dkrˆjjs‚t    d ƒ‚ˆj ¡‰|r°ˆ‡fd!d„ˆjdd"DƒƒS|rút|ƒ‰‡fd#d    „ttˆjƒƒDƒ‰ˆ‡‡fd$d„ˆjdd"DƒƒSˆ‡fd%d„ˆjdd"DƒƒSnt    d&|›d'ƒ‚dS)(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.Mapping 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.Mapping 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'Zseriescss|]\}}||fVqdS©N©©Ú.0ÚkÚvrrúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/methods/to_dict.pyÚ    <genexpr>\szto_dict.<locals>.<genexpr>cSs$g|]\}}t|ƒst|ƒr|‘qSr)rr)rÚiZ    col_dtyperrrÚ
<listcomp>^sþzto_dict.<locals>.<listcomp>r c3s |]\}}|| ˆ¡fVqdSr)Úto_dictr)rrrrfsÚlistc3s<|]4\}\}}||ˆkr*ttt| ¡ƒƒn| ¡fVqdSr)r ÚmaprÚtolist)rrrr©Úobject_dtype_indices_as_setrrrjs 
ûÿürrrÚcolumnsÚdatarcSsg|]}ttt|ƒƒ‘qSr)r r!r©rÚtrrrrŒsÿFN)rÚnameZ index_namesZ column_namesÚrecordsc3s|]}ttˆ|ƒƒVqdSr)r Úzip©rÚrow)r%rrr™scs"g|]}ˆdd„| ¡Dƒƒ‘qS)css|]\}}|t|ƒfVqdSrrrrrrrsz%to_dict.<locals>.<listcomp>.<genexpr>)Úitemsr,)Úinto_crrrœscsg|]}ˆtˆ|ƒƒ‘qSr)r+r')r%r/rrr scsh|]\}}|ˆkr|’qSrr)rrÚcolr#rrÚ    <setcomp>¥sþzto_dict.<locals>.<setcomp>z2DataFrame index must be unique for orient='index'.c
3s4|],}|dttˆjtt|dd…ƒƒƒfVqdS©réN)r r+r%r!rr'©r rrr´sÿ)r)csg|] }|ˆk‘qSrr)rrr#rrrºsc3s6|].}|d‡‡fdd„t|dd…ƒDƒfVqdS)rcs*i|]"\}}ˆ|ˆ|r"t|ƒn|“qSrr)rrr©r%Úis_object_dtype_by_indexrrÚ
<dictcomp>Às
ýÿ
z%to_dict.<locals>.<genexpr>.<dictcomp>r3N)Ú    enumerater'r5rrr½s 
ø üþc3s.|]&}|dttˆj|dd…ƒƒfVqdSr2)r r+r%r'r4rrrÊszorient 'z' not understood)r%Z    is_uniqueÚwarningsÚwarnÚ UserWarningrÚcomZstandardize_mappingÚlowerÚ
ValueErrorr.r8ZdtypesÚvaluesÚlenÚsetZ(_create_data_for_split_and_tight_to_dictrr"Z
itertuplesr ÚnamesrÚrange) r rrrZbox_native_indicesZare_all_object_dtype_colsr&ÚrowsZobject_dtype_colsr-r0r)r%r rr/r6r$rrsÄ5ý
 ÿ
þ 
ù
 
ÿ þÿÿ
ÿ  þþþÿ õ ôÿ
 
 
 ÿ
ÿ  ÿ
þ
 
 
 
þ
 ÿ
 
ö 
ÿ
r)Ú
__future__rÚtypingrr9Zpandas.util._exceptionsrZpandas.core.dtypes.castrZpandas.core.dtypes.commonrrZpandasr    Z pandas.corer
r<r rrrrrÚ<module>s      ú