hyb
2025-12-30 399ffc4d9829f70529d3b096fe4228f7496cc566
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
Ë
nñúhãó —dZddlmZddlmZddlZddlmZddl    m
Z
m Z er ddl m Z ddlmZd d    „Z                                d d
„Z                                                dd „Zy)zH
Module containing utilities for NDFrame.sample() and .GroupBy.sample()
é)Ú annotations)Ú TYPE_CHECKINGN)Úlib)Ú ABCDataFrameÚ    ABCSeries)ÚAxisInt)ÚNDFramecóÖ—t|t«r|j|j|«}t|t«r2t|t
«r|dk(r    ||}ntd«‚td«‚t|t«r |j}n |j}||d¬«j}t|«|j|k7r td«‚tj|«r td    «‚|dkj«r td
«‚t!j"|«}|j«r|j%«}d||<|S#t $r}t d«|‚d}~wwxYw) zþ
    Process and validate the `weights` argument to `NDFrame.sample` and
    `.GroupBy.sample`.
 
    Returns `weights` as an ndarray[np.float64], validated except for normalizing
    weights (because that must be done groupwise in groupby sampling).
    rz+String passed to weights not a valid columnNzLStrings can only be passed to weights when sampling from rows on a DataFramez@Strings cannot be passed as weights when sampling from a Series.Úfloat64)Údtypez5Weights and axis to be sampled must be of same lengthz*weight vector may not include `inf` valuesz.weight vector many not include negative values)Ú
isinstancerÚreindexÚaxesÚstrrÚKeyErrorÚ
ValueErrorÚ _constructorÚ_constructor_slicedÚ_valuesÚlenÚshaperÚhas_infsÚanyÚnpÚisnanÚcopy)ÚobjÚweightsÚaxisÚerrÚfuncÚmissings      úEH:\Change_password\venv_build\Lib\site-packages\pandas/core/sample.pyÚpreprocess_weightsr$sT€ô'œ9Ô%Ø—/‘/ #§(¡(¨4¡.Ó1ˆô'œ3ÔÜ cœ<Ô (ؐqŠyðØ! '™l‘Gô !ð"óðô ØRóð ô#”yÔ!Ø×щà×&Ñ&ˆá7 )Ô,×4Ñ4€Gä
ˆ7ƒ|s—y‘y ‘Ò&ÜÐPÓQÐQä
‡||GÔÜÐEÓFÐFà!‰ ×ÑÔÜÐIÓJÐJäh‰hwÓ€G؇{{„}à—,‘,“.ˆØˆÑØ €NøôI òÜ"ØEóàðûðúsÁEÅ    E(Å E#Å#E(cóΗ|€|€d}|S| | td«‚|%|dkr td«‚|dzdk7r td«‚|S|€J‚|dkDr |s td«‚|dkr td«‚|S)zâ
    Process and validate the `n` and `frac` arguments to `NDFrame.sample` and
    `.GroupBy.sample`.
 
    Returns None if `frac` should be used (variable sampling sizes), otherwise returns
    the constant sampling size.
    éz0Please enter a value for `frac` OR `n`, not bothrz=A negative number of rows requested. Please provide `n` >= 0.z$Only integers accepted as `n` valueszJReplace has to be set to `True` when upsampling the population `frac` > 1.z@A negative number of rows requested. Please provide `frac` >= 0.)r)ÚnÚfracÚreplaces   r#Úprocess_sampling_sizer*Ps¶€ð    €yT\Ø ˆð, €Hð+
ˆ˜4Ð+ÜÐKÓLÐLØ    
ˆØ ˆqŠ5ÜØOóð ð ˆq‰5AŠ:ÜÐCÓDÐ Dð €HðÐÐÐØ !Š8™GÜð8óð ð !Š8ÜØRóð ð €Hócóº—|&|j«}|dk7r||z }n td«‚|j||||¬«jtj
d¬«S)ac
    Randomly sample `size` indices in `np.arange(obj_len)`
 
    Parameters
    ----------
    obj_len : int
        The length of the indices being considered
    size : int
        The number of values to choose
    replace : bool
        Allow or disallow sampling of the same row more than once.
    weights : np.ndarray[np.float64] or None
        If None, equal probability weighting, otherwise weights according
        to the vector normalized
    random_state: np.random.RandomState or np.random.Generator
        State used for the random sampling
 
    Returns
    -------
    np.ndarray[np.intp]
    rz$Invalid weights: weights sum to zero)Úsizer)ÚpF)r)ÚsumrÚchoiceÚastyperÚintp)Úobj_lenr-r)rÚ random_stateÚ
weight_sums      r#Úsampler6ush€ð8ÐØ—[‘[“]ˆ
Ø ˜Š?Ø 
Ñ*‰GäÐCÓDÐ Dà × Ñ ˜w¨T¸7ÀgÐ Ó N× UÑ UÜ
‰eð Vó ðr+)rr    rrÚreturnú
np.ndarray)r'ú
int | Noner(z float | Noner)Úboolr7r9) r3Úintr-r;r)r:rznp.ndarray | Noner4z+np.random.RandomState | np.random.Generatorr7r8)Ú__doc__Ú
__future__rÚtypingrÚnumpyrÚ pandas._libsrÚpandas.core.dtypes.genericrrÚpandas._typingrÚpandas.core.genericr    r$r*r6©r+r#ú<module>rEs‘ðñõ#å ãå÷ñ
Ý&å+ó6ðr" Øð" Ø%ð" Ø04ð" àó" ðJ%Ø ð%à
ð%ðð%ðð    %ð
>ð %ð ô %r+