+
    Ŝio                        R t ^ RIHt ^ RIHt ^ RIt^ RIHt ^ RI	H
t
Ht ]'       d   ^ RIHt ^ RIHt R R	 ltR
 R ltR R ltR# )zH
Module containing utilities for NDFrame.sample() and .GroupBy.sample()
)annotations)TYPE_CHECKINGN)lib)ABCDataFrame	ABCSeries)AxisInt)NDFramec               $    V ^8  d   QhRRRRRR/# )   objr   axisr   return
np.ndarray )formats   "[/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/sample.py__annotate__r      s!     6 6G 6G 6
 6    c                N   \        V\        4      '       d#   VP                  V P                  V,          4      p\        V\        4      '       d>   \        V \
        4      '       d   V^ 8X  d    W,          pM\        R4      h\        R4      h\        V \        4      '       d   V P                  pMV P                  pV! VRR7      P                  p\        V4      V P                  V,          8w  d   \        R4      h\        P                  ! V4      '       d   \        R4      hV^ 8  P                  4       '       d   \        R	4      h\         P"                  ! V4      pVP                  4       '       d   VP%                  4       p^ W&   V#   \         d   p\        R4      ThRp?ii ; i)
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).
z+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)r   weightsr   errfuncmissings   &&&   r   preprocess_weightsr+      sd    '9%%//#((4.1 '3c<((qy!lG !"  R  #y!!&&7),44G
7|syy&PQQ
||GEFF!IJJhhwG{{}},,.NI   "Es   -F F$FF$c               (    V ^8  d   QhRRRRRRRR/# )r
   nz
int | Nonefraczfloat | Nonereplaceboolr   r   )r   s   "r   r   r   Q   s,     " ""%"04""r   c                   V f	   Vf   ^p V # V e   Ve   \        R4      hV e/   V ^ 8  d   \        R4      hV ^,          ^ 8w  d   \        R4      h V # Vf   Q hV^8  d   V'       g   \        R4      hV^ 8  d   \        R4      hV # )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 bothz=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   )r-   r.   r/   s   &&&r   process_sampling_sizer2   Q   s     	yT\, H+ 
4+KLL	
q5O  q5A:CDD  H !8G8  !8R  Hr   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r
   obj_lenintsizer/   r0   r'   znp.ndarray | Nonerandom_statez+np.random.RandomState | np.random.Generatorr   r   r   )r   s   "r   r   r   v   sD     - --
- - 	-
 >- -r   c                ,   Ve`   VP                  4       pV^ 8w  d
   W5,          pM\        R4      hVf   Q hV'       g'   WP                  4       ,          ^8  d   \        R4      hVP                  WW#R7      P	                  \
        P                  RR7      # )a  
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]
z$Invalid weights: weights sum to zerozWeighted sampling cannot be achieved with replace=False. Either set replace=True or use smaller weights. See the docstring of sample for details.)r6   r/   pF)r&   )sumr   maxchoiceastyper$   intp)r4   r6   r/   r'   r7   
weight_sums   &&&&& r   sampler@   v   s    8 [[]
?*GCDD"""4++-/!3&  w7NUU
e V  r   )__doc__
__future__r   typingr   numpyr$   pandas._libsr   pandas.core.dtypes.genericr   r   pandas._typingr   pandas.core.genericr   r+   r2   r@   r   r   r   <module>rI      s9    #    
 &+6r"J-r   