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
U
­ý°dvã@s˜dZddlmZddlZddlZddlZddlZddlm    Z    ddl
m Z ddl Z ddlmZmZddlmZGdd    „d    e ƒZGd
d „d eƒZd d „ZdS)zp
Test extension array for storing nested data in a pandas container.
 
The ListArray stores an ndarray of lists.
é)Ú annotationsN)Útype_t)ÚExtensionDtype)Úis_object_dtypeÚis_string_dtype)ÚExtensionArrayc@s,eZdZeZdZejZe    ddœdd„ƒZ
dS)Ú    ListDtypeÚlistztype_t[ListArray]©ÚreturncCstS)zq
        Return the array type associated with this dtype.
 
        Returns
        -------
        type
        )Ú    ListArray)Úcls©rúXd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/extension/list/array.pyÚconstruct_array_types    zListDtype.construct_array_typeN) Ú__name__Ú
__module__Ú __qualname__r    ÚtypeÚnameÚnpÚnanÚna_valueÚ classmethodrrrrrrs
rc@szeZdZeƒZdZdddœdd„Zeddd    „ƒZd
d „Z    d dœd d„Z
dd„Z ddd„Z dd„Z ddd„Zedd„ƒZdS)r ièNFÚNoner
cCsTt|tjƒstdƒ‚|D]0}t||jjƒst |¡stdt|jjƒƒ‚q||_    dS)Nz$Need to pass a numpy array as valueszAll values must be of type )
Ú
isinstancerZndarrayÚ    TypeErrorÚdtyperÚpdÚisnaÚstrÚdata)ÚselfÚvaluesrÚcopyÚvalrrrÚ__init__/s  zListArray.__init__cCs&tjt|ƒtd}||dd…<||ƒS)N©r)rÚemptyÚlenÚobject)r Zscalarsrr$r!rrrÚ_from_sequence7s zListArray._from_sequencecCs,t|tjƒr|j|St|ƒ|j|ƒSdS©N)rÚnumbersÚIntegralr!r)r"ÚitemrrrÚ __getitem__=s 
zListArray.__getitem__ÚintcCs
t|jƒSr,)r)r!©r"rrrÚ__len__DszListArray.__len__cCstjdd„|jDƒtdS)NcSs"g|]}t|tƒ ot |¡‘qSr)rr    rÚisnan©Ú.0ÚxrrrÚ
<listcomp>Isz"ListArray.isna.<locals>.<listcomp>r')rÚarrayr!Úboolr2rrrrGsÿzListArray.isnac
sÈt |¡}d}|rzˆdkr"ˆjj‰|dk ¡r2t‚z‡‡fdd„|Dƒ}Wq¾tk
rv}zt|ƒ|‚W5d}~XYq¾XnDz‡fdd„|Dƒ}Wn,tk
r¼}zt|ƒ|‚W5d}~XYnXˆ |¡S)NzIIndex is out of bounds or cannot do a non-empty take from an empty array.éÿÿÿÿcs"g|]}|dkrˆj|nˆ‘qS)r;©r!©r6Úloc©Ú
fill_valuer"rrr8]sz"ListArray.take.<locals>.<listcomp>csg|]}ˆj|‘qSrr<r=r2rrr8ds)rZasarrayrrÚanyÚ
ValueErrorÚ
IndexErrorr+)r"ZindexerZ
allow_fillr@ÚmsgÚoutputÚerrrr?rÚtakeLs&
ÿ  ÿ
zListArray.takecCst|ƒ|jdd…ƒSr,)rr!r2rrrr$jszListArray.copyTcCsft|t|jƒƒr*||jkr*|r&| ¡S|St|ƒrTt|ƒsTtjdd„|jDƒ|dStj|j||dS)NcSsg|] }t|ƒ‘qSr)r r5rrrr8tsz$ListArray.astype.<locals>.<listcomp>r')rr$)    rrrr$rrrr9r!)r"rr$rrrÚastypemszListArray.astypecCst dd„|Dƒ¡}||ƒS)NcSsg|]
}|j‘qSrr<r5rrrr8ysz/ListArray._concat_same_type.<locals>.<listcomp>)rZ concatenate)r Z    to_concatr!rrrÚ_concat_same_typewszListArray._concat_same_type)NF)NF)FN)T)rrrrrZ__array_priority__r&rr+r0r3rrGr$rHrIrrrrr +s 
 
 
r cCs,tjdtd}dd„tdƒDƒ|dd…<|S)Nédr'cSs&g|]}dd„tt dd¡ƒDƒ‘qS)cSsg|]}t tj¡‘qSr)ÚrandomÚchoiceÚstringÚ ascii_letters©r6Ú_rrrr8sz(make_data.<locals>.<listcomp>.<listcomp>ré
)ÚrangerKÚrandintrOrrrr8€sÿzmake_data.<locals>.<listcomp>)rr(r*rRr<rrrÚ    make_data}s
þrT)Ú__doc__Ú
__future__rr-rKrMÚnumpyrZpandas._typingrZpandas.core.dtypes.baserZpandasrZpandas.api.typesrrZpandas.core.arraysrrr rTrrrrÚ<module>s    R