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
U
¬ý°doã@s¼dZddlmZddlmZmZmZddlZddl    m
Z
m Z m Z m Z ddlmZddlmZmZddlmZdd    lmZmZed
d d ZGd d „d eƒZGdd„deƒZdddœdd„ZdS)zc
Base class for the internal managers. Both BlockManager and ArrayManager
inherit from this class.
é)Ú annotations)ÚLiteralÚTypeVarÚfinalN)Ú    ArrayLikeÚAxisIntÚDtypeObjÚShape©ÚAbstractMethodError)Úfind_common_typeÚnp_can_hold_element)Ú PandasObject)ÚIndexÚ default_indexÚTÚ DataManager)Úboundc@s$eZdZUded<eddœdd„ƒZeddœdd    „ƒZeddœd
d „ƒZed dœd d„ƒZ    eddddœdd„ƒZ
d3dddddddœdd„Z ed4ddddddœdd„ƒZ ddddœd d!„Z ed"dd#œd$d%„ƒZd5dd&dd'œd(d)„Zeddd*œd+d,„ƒZddœd-d.„Zddd*œd/d0„Zddœd1d2„ZdS)6rz list[Index]Úaxesr©ÚreturncCs t|ƒ‚dS©Nr
©Úself©rúQd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/internals/base.pyÚitems*szDataManager.itemsÚintcCs
t|jƒSr)ÚlenrrrrrÚ__len__.szDataManager.__len__cCs
t|jƒSr)rrrrrrÚndim2szDataManager.ndimr    cCstdd„|jDƒƒS)Ncss|]}t|ƒVqdSr)r)Ú.0ZaxrrrÚ    <genexpr>8sz$DataManager.shape.<locals>.<genexpr>)ÚtuplerrrrrÚshape6szDataManager.shaperÚNone)ÚaxisÚ
new_labelsrcCsPt|j|ƒ}t|ƒ}|dkr.t|jƒdkr.n||krLtd|›d|›dƒ‚dS)Nérz#Length mismatch: Expected axis has z elements, new values have z     elements)rrrÚ
ValueError)rr&r'Zold_lenZnew_lenrrrÚ_validate_set_axis:sÿzDataManager._validate_set_axisNFTrÚbool)rr&Ú
allow_dupsÚcopyÚ
only_slicercCs t|ƒ‚dSrr
)rZnew_axisÚindexerr&Ú
fill_valuer,r-r.rrrÚreindex_indexerKs
zDataManager.reindex_indexer)rÚ    new_indexr&r.rcCs*|j| |¡\}}|j||||d|dS)z4
        Conform data manager to new index.
        F)r&r0r-r.)rZreindexr1)rr2r&r0r.r/rrrÚ reindex_axisWs úzDataManager.reindex_axis)rÚotherrcCs t|ƒ‚dS)z‘
        To be implemented by the subclasses. Only check the column values
        assuming shape and indexes have already been checked.
        Nr
)rr4rrrÚ _equal_valuesmszDataManager._equal_valuesÚobject)r4rcCsVt|tƒsdS|j|j}}t|ƒt|ƒkr0dStdd„t||ƒDƒƒsLdS| |¡S)z5
        Implementation for DataFrame.equals
        Fcss|]\}}| |¡VqdSr)Úequals)r!Zax1Zax2rrrr"sz%DataManager.equals.<locals>.<genexpr>)Ú
isinstancerrrÚallÚzipr5)rr4Z    self_axesZ
other_axesrrrr7ts
zDataManager.equalszlist[str] | None)rÚ
align_keysrcKs t|ƒ‚dSrr
)rÚfr;ÚkwargsrrrÚapply„szDataManager.apply)rrcCs|jd|dS)Nr>)Úfunc)r>)rr?rrrÚisnaŒszDataManager.isnacCsdS)NTrrrrrÚis_consolidated“szDataManager.is_consolidatedcCs|SrrrrrrÚ consolidate–szDataManager.consolidatecCsdSrrrrrrÚ_consolidate_inplace™sz DataManager._consolidate_inplace)NFTF)NF)N)Ú__name__Ú
__module__Ú __qualname__Ú__annotations__Úpropertyrrrr r$r*r1r3r5r7r>r@rArBrCrrrrr%s<
ø ûýc@s^eZdZeddœdd„ƒZeeddœdd„ƒƒZddœd    d
„Zd d „Ze    dd dœdd„ƒZ
dS)ÚSingleDataManagerz
Literal[1]rcCsdS)Nr(rrrrrr žszSingleDataManager.ndimrcCs
|jdS)zW
        Quick access to the backing array of the Block or SingleArrayManager.
        r)ZarraysrrrrÚarray¢szSingleDataManager.arrayr%cCs*|j}t|tjƒrt|j|ƒ}|||<dS)a'
        Set values with indexer.
 
        For Single[Block/Array]Manager, this backs s[indexer] = value
 
        This is an inplace version of `setitem()`, mutating the manager/values
        in place, not returning a new Manager (and Block), and thus never changing
        the dtype.
        N)rJr8ÚnpZndarrayr Zdtype)rr/ÚvalueÚarrrrrÚsetitem_inplace«s
  z!SingleDataManager.setitem_inplacecCs.|j}||ƒ}tt|ƒƒ}t|ƒ ||¡}|Sr)rJrrÚtypeÚ
from_array)rr?rMÚresÚindexZmgrrrrÚgrouped_reduce¿s
 z SingleDataManager.grouped_reducer)rMrRcCs t|ƒ‚dSrr
)ÚclsrMrRrrrrPÇszSingleDataManager.from_arrayN) rDrErFrHr rrJrNrSÚ classmethodrPrrrrrIsrIzlist[DtypeObj]zDtypeObj | None)ÚdtypesrcCst|ƒs dSt|ƒS)zà
    Find the common dtype for `blocks`.
 
    Parameters
    ----------
    blocks : List[DtypeObj]
 
    Returns
    -------
    dtype : np.dtype, ExtensionDtype, or None
        None is returned when `blocks` is empty.
    N)rr )rVrrrÚinterleaved_dtypeÌs rW)Ú__doc__Ú
__future__rÚtypingrrrÚnumpyrKZpandas._typingrrrr    Z pandas.errorsr Zpandas.core.dtypes.castr r Zpandas.core.baserZpandas.core.indexes.apirrrrrIrWrrrrÚ<module>s    x/