
    MhƉ                    h   S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
  SSKrSSKJrJrJr  SSKJrJrJrJrJr  SSKJr  SS	KJr  SS
KJrJrJrJrJ r J!r!  SSK"J#r#  SSK$J%r%J&r&J'r'  \(       a  SSK(J)r)  S4S jr*S5S jr+\
SS.     S6S jj5       r,\
      S7S j5       r,SS.     S8S jjr,/ SQr-/ SQr.S9S jr/S:S jr0    S;S jr1S<S jr2      S=S jr3S>S jr4      S?                 S@S jjr5SAS jr6        SB                   SCS  jjr7   SD         SES! jjr8   SF         SGS" jjr9  SH         SIS# jjr:   SJ         SKS$ jjr;          SLS% jr<    SM           SNS& jjr= SO   SPS' jjr>SQS( jr?\?   SR         SSS) jj5       r@\?   SR         SSS* jj5       rA\?   SR       STS+ jj5       rB\?   SR     SUS, jj5       rC      SVS- jrD      SVS. jrE\@\AS/.rFSWSXS0 jjrGSYS1 jrH      SZS2 jrIS[S3 jrJg)\z$
Routines for filling missing data.
    )annotations)wraps)TYPE_CHECKINGAnyLiteralcastoverloadN)NaTalgoslib)	ArrayLikeAxisIntFReindexMethodnpt)import_optional_dependency)infer_dtype_from)is_array_likeis_bool_dtypeis_numeric_dtypeis_numeric_v_string_likeis_object_dtypeneeds_i8_conversion)DatetimeTZDtype)is_valid_na_for_dtypeisnana_value_for_dtypeIndexc                    [        U 5      (       a-  [        U 5      U:w  a  [        S[        U 5       SU 35      eX   n U $ )zB
Validate the size of the values passed to ExtensionArray.fillna.
z'Length of 'value' does not match. Got (z)  expected )r   len
ValueError)valuemasklengths      E/var/www/html/env/lib/python3.13/site-packages/pandas/core/missing.pycheck_value_sizer'   3   sQ     Uu:9#e* F#H&  L    c                j   [        U5      u  p![        U[        R                  5      (       a  [        R                  " XS9nO>UR                  5       n[        R                  " U5      (       d  U/nUR                  XSS9nSn[        U R                  5      (       a  Sn[        U 5      ) n[        U5      nX)    n[        R                  " U R                  [        S9n[        U R                  5      (       a5  [        U R                  5      (       d  [        UR                  5      (       a  O[        U R                  5      (       a5  [        UR                  5      (       a  [        UR                  5      (       d  OU H  n	[!        X	5      (       a  M  U(       a8  [        R                  " U R                  [        R"                  S9n
U W   U	:H  X'   O7X	:H  n
[        U
[        R$                  5      (       d  U
R'                  [        SS9n
X-  nM     UR)                  5       (       a  U[        U 5      -  nU$ )z
Return a masking array of same size/shape as arr
with entries equaling any member of values_to_mask set to True

Parameters
----------
arr : ArrayLike
values_to_mask: list, tuple, or scalar

Returns
-------
np.ndarray[bool]
)dtypeF)r*   copyT)r*   na_value)r   
isinstancenpr*   arrayconstruct_array_typer   is_list_like_from_sequencer   r   zerosshapeboolr   r   r   bool_ndarrayto_numpyany)arrvalues_to_maskr*   clspotential_naarr_maskna_masknonnar$   xnew_masks              r&   mask_missingrC   B   s   " -^<E%"".>((*//,-N++Ne+TLsyy!!I:>"G8$E 88CIIT*D##cii((%++&&cii  U[[))ekk**A'//!xx		BH),X!);H&"xH%h

;;#+#4#44%#4#P    {{}}S	Kr(   .allow_nearestc                   g N methodrE   s     r&   clean_fill_methodrK           r(   c                   g rG   rH   rI   s     r&   rK   rK      rL   r(   Fc                   [        U [        5      (       a!  U R                  5       n U S:X  a  Sn OU S:X  a  Sn SS/nSnU(       a  UR                  S5        SnX;  a  [	        SU S	U  35      eU $ )
Nffillpadbfillbackfillzpad (ffill) or backfill (bfill)nearestz(pad (ffill), backfill (bfill) or nearestzInvalid fill method. Expecting z. Got )r-   strlowerappendr"   )rJ   rE   valid_methods	expectings       r&   rK   rK      s    
 &# WFwFJ'M1IY'>	":9+VF8TUUMr(   )lineartimeindexvalues)rS   zeroslinear	quadraticcubicbarycentrickroghspline
polynomialfrom_derivativespiecewise_polynomialpchipakimacubicsplinec                    UR                  S5      nU S;   a  Uc  [        S5      e[        [        -   nX;  a  [        SU SU  S35      eU S;   a  UR                  (       d  [        U  S35      eU $ )	Norder)rc   rd   z7You must specify the order of the spline or polynomial.zmethod must be one of z. Got 'z
' instead.)rb   rf   rg   z4 interpolation requires that the index be monotonic.)getr"   
NP_METHODS
SP_METHODSis_monotonic_increasing)rJ   r[   kwargsrk   valids        r&   clean_interp_methodrr      s    JJwE))emRSS#E1%xzRSS;;,,(NO  Mr(   c                   U S;   d   e[        U5      S:X  a  gUR                  S:X  a  UR                  SS9nU S:X  a  USS R                  5       nO+U S:X  a%  [        U5      S-
  USSS	2   R                  5       -
  nUW   nU(       d  gU$ )
z
Retrieves the positional index of the first valid value.

Parameters
----------
how : {'first', 'last'}
    Use this parameter to change between the first or last valid index.
is_valid: np.ndarray
    Mask to find na_values.

Returns
-------
int or None
)firstlastr   N      axisrt   ru   )r!   ndimr9   argmax)howis_valididxpos	chk_notnas       r&   find_valid_indexr      s     ####
8}}}<<Q<'
g~"$$&	X"Xdd^%:%:%<< I Mr(   c                \    / SQnU R                  5       n X;  a  [        SU SU  S35      eU $ )N)forwardbackwardbothz*Invalid limit_direction: expecting one of z, got 'z'.rU   r"   )limit_directionvalid_limit_directionss     r&   validate_limit_directionr     sK     =%++-O48%&go->bB
 	
 r(   c                b    U b+  SS/nU R                  5       n X;  a  [        SU SU  S35      eU $ )Ninsideoutsidez%Invalid limit_area: expecting one of z, got .r   )
limit_areavalid_limit_areass     r&   validate_limit_arear     sS    %y1%%'
.78I7J&,a!  r(   c                    U c  US;   a  Sn U $ Sn  U $ US;   a  U S:w  a  [        SU S35      eUS;   a  U S:w  a  [        SU S35      eU $ )N)rR   rQ   r   r   )rP   rO   z0`limit_direction` must be 'forward' for method ``z1`limit_direction` must be 'backward' for method `)r"   )r   rJ   s     r&   infer_limit_directionr   #  s     **(O  (O  %%/Y*FB6(!L  ***/LCF81M  r(   c                   U S:X  a,  SSK Jn  U" [        R                  " [	        U5      5      5      nO}1 Skn[        UR                  5      =(       dB    [        UR                  [        5      =(       d!    [        R                  " UR                  S5      nX;  a  U(       d  [        SU  S35      e[        U5      R                  5       (       a  [        S5      eU$ )	NrY   r   r   >   rZ   r[   r\   rS   mMz9Index column must be numeric or datetime type when using z_ method other than linear. Try setting a numeric or datetime index column before interpolating.zkInterpolation with NaNs in the index has not been implemented. Try filling those NaNs before interpolating.)pandasr   r.   aranger!   r   r*   r-   r   r   is_np_dtyper"   r   r9   NotImplementedError)rJ   r[   r   methodsis_numeric_or_datetimes        r&   get_interp_indexr   8  s     biiE
+,8U[[) 2%++72u{{D1 	
  )? !!!  E{!/
 	

 Lr(   c	           	       ^^^^^^	^^ [        TU40 T	D6  [        TU R                  5      (       a  [        U R                  SS9mTS:X  a'  [	        UR                  5      (       d  [        S5      eSm[        T5      m[        U5      m[        R                  " STS9m[        UT5      mS	UUU	UUUUU4S jjn
[        R                  " XU 5        g)
z
Column-wise application of _interpolate_1d.

Notes
-----
Alters 'data' in-place.

The signature does differ from _interpolate_1d because it only
includes what is needed for Block.interpolate.
F)compatrZ   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexr\   N)nobslimitc                0   > [        STU TTTTTSTS.	TD6  g )NF)	indicesyvaluesrJ   r   r   r   
fill_valuebounds_errorr$   rH   )_interpolate_1d)	r   r   r   rp   r   limit_area_validatedr   r$   rJ   s	    r&   func$interpolate_2d_inplace.<locals>.func  s7     	 	
++!	
 	
r(   )r   
np.ndarrayreturnNone)rr   r   r*   r   r   r"   r   r   r   validate_limit_index_to_interp_indicesr.   apply_along_axis)datar[   ry   rJ   r   r   r   r   r$   rp   r   r   r   s      ``` ``` @@r&   interpolate_2d_inplacer   W  s    . 00Z44'

5A
"5;;//  
 .?O.z:   d%8E&uf5G
 
, D)r(   c                \   U R                   n[        UR                  5      (       a  UR                  S5      nUS:X  a  Un[	        [
        R                  U5      nU$ [
        R                  " U5      nUS;   a4  UR                  [
        R                  :X  a  [        R                  " U5      nU$ )z=
Convert Index to ndarray of indices to pass to NumPy/SciPy.
i8rY   )r\   r[   )_valuesr   r*   viewr   r.   r7   asarrayobject_r   maybe_convert_objects)r[   rJ   xarrindss       r&   r   r     s     ==D4::&&yyBJJ% K zz$((zzRZZ'006Kr(   c
                   U	b  U	nO[        U5      nU) nUR                  5       (       d  gUR                  5       (       a  g[        [        R
                  " U5      5      n[        SUS9nUc  Sn[        [        U5      5      n[        SUS9nUc  [        U5      n[        [        SU-   [        U5      5      5      nUS:X  a  U[        [        XS5      5      -  nO5US:X  a  U[        [        USU5      5      -  nO[        [        XU5      5      nUS	:X  a	  UUU-  -  nOUS
:X  a  X-
  U-
  nUU-  n[        U5      nUR                  R                  S;   nU(       a  UR                  S5      nU[        ;   a?  [        R                  " X   5      n[        R                   " X   X   U   X   U   5      X'   O[#        X   X   X   4UUUUS.U
D6X'   U	b  SU	SS& SU	U'   gU(       a  [$        R&                  UU'   g[        R(                  UU'   g)z
Logic for the 1-d interpolation.  The input
indices and yvalues will each be 1-d arrays of the same length.

Bounds_error is currently hardcoded to False since non-scipy ones don't
take it as an argument.

Notes
-----
Fills 'yvalues' in-place.
Nrt   r}   r~   r   ru   rw   r   r   r   r   r   r   )rJ   r   r   rk   FT)r   r9   allsetr.   flatnonzeror   ranger!   _interp_limitsortedr*   kindr   rm   argsortinterp_interpolate_scipy_wrapperr
   r#   nan)r   r   rJ   r   r   r   r   r   rk   r$   rp   invalidrq   all_nansfirst_valid_index
start_nanslast_valid_indexend_nanspreserve_nansmid_nansis_datetimelikeindexers                         r&   r   r     s7   0 w-HE99;;yy{{ 2>>'*+H(WuE U,-.J'FUCw<5--s5z:;H )#"Swq)I%JJ	J	& 3}Wa'G#HH M'%@A Xh..	y	 (83! =)Mmm((D0O,,t$ **W^,99gnW5w~g7N
 6NN	
 !%	
 	
 Q"]
 	 
!$  "$
r(   c                   U S3n[        SUS9  SSKJn	  [        R                  " U5      nU	R
                  U	R                  [        [        [        [        U	R                  S.n
/ SQnX;;   a&  US:X  a  UnOUnU	R                  XXUS	9nU" U5      nU$ US
:X  aC  [        U5      (       d  US::  a  [        SU 35      eU	R                  " X4SU0UD6nU" U5      nU$ U R                  R                   (       d  U R#                  5       n UR                  R                   (       d  UR#                  5       nUR                  R                   (       d  UR#                  5       nX   nU" XU40 UD6nU$ )z
Passed off to scipy.interpolate.interp1d. method is scipy's kind.
Returns an array interpolated at new_x.  Add any new methods to
the list in _clean_interp_method.
z interpolation requires SciPy.scipy)extrar   interpolate)ra   rb   re   rf   ri   rh   rg   )rS   r]   r^   r_   r`   rd   rd   )r   r   r   rc   z;order needs to be specified and greater than 0; got order: k)r   r   r   r.   r   barycentric_interpolatekrogh_interpolate_from_derivatives_cubicspline_interpolate_akima_interpolatepchip_interpolateinterp1dr   r"   UnivariateSplineflags	writeabler+   )rA   ynew_xrJ   r   r   rk   rp   r   r   alt_methodsinterp1d_methodsr   terpnew_ys                  r&   r   r   %  sp    h45Ewe4!JJuE #::..- 1/#..K !\!DD##t $ 
 U( L' 
8	;;5A:MeWU  ++ADEDVDU L ww  Aww  A{{$$JJLE"Q5+F+Lr(   c                x    SSK Jn  UR                  R                  nU" XR	                  SS5      X5S9nU" U5      $ )a/  
Convenience function for interpolate.BPoly.from_derivatives.

Construct a piecewise polynomial in the Bernstein basis, compatible
with the specified values and derivatives at breakpoints.

Parameters
----------
xi : array-like
    sorted 1D array of x-coordinates
yi : array-like or list of array-likes
    yi[i][j] is the j-th derivative known at xi[i]
order: None or int or array-like of ints. Default: None.
    Specifies the degree of local polynomials. If not None, some
    derivatives are ignored.
der : int or list
    How many derivatives to extract; None for all potentially nonzero
    derivatives (that is a number equal to the number of points), or a
    list of derivatives to extract. This number includes the function
    value as 0th derivative.
 extrapolate : bool, optional
    Whether to extrapolate to ouf-of-bounds points based on first and last
    intervals, or to return NaNs. Default: True.

See Also
--------
scipy.interpolate.BPoly.from_derivatives

Returns
-------
y : scalar or array-like
    The result, of length R or length M or M by R.
r   r   rz   rw   )ordersextrapolate)r   r   BPolyre   reshape)	xiyirA   rk   derr   r   rJ   ms	            r&   r   r   l  s;    R " //Fr::b!$ULAQ4Kr(   c                :    SSK Jn  UR                  XUS9nU" X#S9$ )a  
Convenience function for akima interpolation.
xi and yi are arrays of values used to approximate some function f,
with ``yi = f(xi)``.

See `Akima1DInterpolator` for details.

Parameters
----------
xi : np.ndarray
    A sorted list of x-coordinates, of length N.
yi : np.ndarray
    A 1-D array of real values.  `yi`'s length along the interpolation
    axis must be equal to the length of `xi`. If N-D array, use axis
    parameter to select correct axis.
x : np.ndarray
    Of length M.
der : int, optional
    How many derivatives to extract; None for all potentially
    nonzero derivatives (that is a number equal to the number
    of points), or a list of derivatives to extract. This number
    includes the function value as 0th derivative.
axis : int, optional
    Axis in the yi array corresponding to the x-coordinate values.

See Also
--------
scipy.interpolate.Akima1DInterpolator

Returns
-------
y : scalar or array-like
    The result, of length R or length M or M by R,

r   r   rx   )nu)r   r   Akima1DInterpolator)r   r   rA   r   ry   r   Ps          r&   r   r     s'    T "''T':AQ<r(   c                @    SSK Jn  UR                  XX4US9nU" U5      $ )ak  
Convenience function for cubic spline data interpolator.

See `scipy.interpolate.CubicSpline` for details.

Parameters
----------
xi : np.ndarray, shape (n,)
    1-d array containing values of the independent variable.
    Values must be real, finite and in strictly increasing order.
yi : np.ndarray
    Array containing values of the dependent variable. It can have
    arbitrary number of dimensions, but the length along ``axis``
    (see below) must match the length of ``x``. Values must be finite.
x : np.ndarray, shape (m,)
axis : int, optional
    Axis along which `y` is assumed to be varying. Meaning that for
    ``x[i]`` the corresponding values are ``np.take(y, i, axis=axis)``.
    Default is 0.
bc_type : string or 2-tuple, optional
    Boundary condition type. Two additional equations, given by the
    boundary conditions, are required to determine all coefficients of
    polynomials on each segment [2]_.
    If `bc_type` is a string, then the specified condition will be applied
    at both ends of a spline. Available conditions are:
    * 'not-a-knot' (default): The first and second segment at a curve end
      are the same polynomial. It is a good default when there is no
      information on boundary conditions.
    * 'periodic': The interpolated functions is assumed to be periodic
      of period ``x[-1] - x[0]``. The first and last value of `y` must be
      identical: ``y[0] == y[-1]``. This boundary condition will result in
      ``y'[0] == y'[-1]`` and ``y''[0] == y''[-1]``.
    * 'clamped': The first derivative at curves ends are zero. Assuming
      a 1D `y`, ``bc_type=((1, 0.0), (1, 0.0))`` is the same condition.
    * 'natural': The second derivative at curve ends are zero. Assuming
      a 1D `y`, ``bc_type=((2, 0.0), (2, 0.0))`` is the same condition.
    If `bc_type` is a 2-tuple, the first and the second value will be
    applied at the curve start and end respectively. The tuple values can
    be one of the previously mentioned strings (except 'periodic') or a
    tuple `(order, deriv_values)` allowing to specify arbitrary
    derivatives at curve ends:
    * `order`: the derivative order, 1 or 2.
    * `deriv_value`: array-like containing derivative values, shape must
      be the same as `y`, excluding ``axis`` dimension. For example, if
      `y` is 1D, then `deriv_value` must be a scalar. If `y` is 3D with
      the shape (n0, n1, n2) and axis=2, then `deriv_value` must be 2D
      and have the shape (n0, n1).
extrapolate : {bool, 'periodic', None}, optional
    If bool, determines whether to extrapolate to out-of-bounds points
    based on first and last intervals, or to return NaNs. If 'periodic',
    periodic extrapolation is used. If None (default), ``extrapolate`` is
    set to 'periodic' for ``bc_type='periodic'`` and to True otherwise.

See Also
--------
scipy.interpolate.CubicHermiteSpline

Returns
-------
y : scalar or array-like
    The result, of shape (m,)

References
----------
.. [1] `Cubic Spline Interpolation
        <https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation>`_
        on Wikiversity.
.. [2] Carl de Boor, "A Practical Guide to Splines", Springer-Verlag, 1978.
r   r   )ry   bc_typer   )r   r   CubicSpline)r   r   rA   ry   r   r   r   r   s           r&   r   r     s/    Z "
T 	  	A Q4Kr(   c                .   [        U 5      nU) nUR                  5       (       dr  [        SUS9nUc  Sn[        SUS9nUc  [        U 5      n[	        U UUUS9  US:X  a  SXFUS	-   & OUS
:X  a  S=USU& XGS	-   S& O[        S5      e[        R                  X'   gg)ao  
Apply interpolation and limit_area logic to values along a to-be-specified axis.

Parameters
----------
values: np.ndarray
    Input array.
method: str
    Interpolation method. Could be "bfill" or "pad"
limit: int, optional
    Index limit on interpolation.
limit_area: {'inside', 'outside'}
    Limit area for interpolation.

Notes
-----
Modifies values in-place.
rt   r   Nr   ru   )rJ   r   r   r   Frw   r   z*limit_area should be 'inside' or 'outside')r   r   r   r!   pad_or_backfill_inplacer"   r.   r   )r\   rJ   r   r   r   r~   rt   ru   s           r&   _interpolate_with_limit_arear   %  s    2 6lGxH;;== Wx@=EFX><v;D!		
 !(-GD1H%9$499GFUOgQhj1IJJ&&- r(   c                    US:X  a  S OS nU R                   S:X  a8  US:w  a  [        S5      eU R                  [        SU R                  -   5      5      n [        U5      nU" U 5      n[        USS9nU" XcUS	9  g
)a  
Perform an actual interpolation of values, values will be make 2-d if
needed fills inplace, returns the result.

Parameters
----------
values: np.ndarray
    Input array.
method: str, default "pad"
    Interpolation method. Could be "bfill" or "pad"
axis: 0 or 1
    Interpolation axis
limit: int, optional
    Index limit on interpolation.
limit_area: str, optional
    Limit area for interpolation. Can be "inside" or "outside"

Notes
-----
Modifies values in-place.
r   c                    U $ rG   rH   rA   s    r&   <lambda>)pad_or_backfill_inplace.<locals>.<lambda>v  s    r(   c                    U R                   $ rG   )Tr   s    r&   r   r   v  s    r(   rw   z0cannot interpolate on a ndim == 1 with axis != 0rw   rv   )r{   )r   r   N)r{   AssertionErrorr   tupler4   rK   get_fill_func)r\   rJ   ry   r   r   transftvaluesr   s           r&   r   r   Z  sw    8 #aikmF {{a19 !STTdV\\&9 :;v&FVnGa(D*5r(   c                "    Uc  [        U 5      nU$ rG   )r   )r\   r$   s     r&   _fillna_prepr	    s    
 |F|Kr(   c                `   ^  [        T 5         S   SU 4S jjj5       n[        [        U5      $ )z6
Wrapper to handle datetime64 and timedelta64 dtypes.
c                   > [        U R                  5      (       aD  Uc  [        U 5      nT" U R                  S5      XUS9u  pCUR                  U R                  5      U4$ T" XX#S9$ )Nr   )r   r   r$   )r   r*   r   r   )r\   r   r   r$   resultr   s        r&   new_func&_datetimelike_compat.<locals>.new_func  se     v||,,|F|D!DLF ;;v||,d22FJJJr(   NNN)r   
int | Noner   #Literal['inside', 'outside'] | None)r   r   r   )r   r  s   ` r&   _datetimelike_compatr    sK    
 4[ !:>	KK 8K K$ 8r(   c                    [        X5      nUb   UR                  5       (       d  [        X25        [        R                  " XUS9  X4$ N)r   )r	  r   _fill_limit_area_1dr   pad_inplacer\   r   r   r$   s       r&   _pad_1dr    s>     %DdhhjjD-	f%0<r(   c                    [        X5      nUb   UR                  5       (       d  [        X25        [        R                  " XUS9  X4$ r  )r	  r   r  r   backfill_inplacer  s       r&   _backfill_1dr    s>     %DdhhjjD-	6u5<r(   c                    [        X5      nUb  [        X25        U R                  (       a  [        R                  " XUS9  X4$  X4$ r  )r	  _fill_limit_area_2dsizer   pad_2d_inplacer  s       r&   _pad_2dr     sJ     %DD-{{V7 < 	<r(   c                    [        X5      nUb  [        X25        U R                  (       a  [        R                  " XUS9  X4$  X4$ r  )r	  r  r  r   backfill_2d_inplacer  s       r&   _backfill_2dr#    sJ     %DD-{{!!&e< < 	<r(   c                    U ) nUR                  5       n[        U5      USSS2   R                  5       -
  S-
  nUS:X  a  SU SU& SXS-   S& gUS:X  a  SXS-   U& gg)a  Prepare 1d mask for ffill/bfill with limit_area.

Caller is responsible for checking at least one value of mask is False.
When called, mask will no longer faithfully represent when
the corresponding are NA or not.

Parameters
----------
mask : np.ndarray[bool, ndim=1]
    Mask representing NA values when filling.
limit_area : { "outside", "inside" }
    Whether to limit filling to outside or inside the outer most non-NA value.
Nrz   rw   r   Fr   )r|   r!   )r$   r   neg_maskrt   ru   s        r&   r  r    sw      uHOOEx=8DbD>0022Q6DXVe AXZ	y	 !&QY 
!r(   c                p   U R                   ) nUS:X  aJ  [        R                  R                  USS9[        R                  R                  USSS2   SS9SSS2   -  nOK[        R                  R                  USS9) [        R                  R                  USSS2   SS9SSS2   ) -  nSXR                   '   g)ag  Prepare 2d mask for ffill/bfill with limit_area.

When called, mask will no longer faithfully represent when
the corresponding are NA or not.

Parameters
----------
mask : np.ndarray[bool, ndim=1]
    Mask representing NA values when filling.
limit_area : { "outside", "inside" }
    Whether to limit filling to outside or inside the outer most non-NA value.
r   r   rx   Nrz   F)r  r.   maximum
accumulate)r$   r   r%  la_masks       r&   r  r    s     wHY JJ!!(!3jj##HTrTN#;DbDAB 	 ZZ""8!"44zz$$Xdd^!$<TrTBBC 	 DOr(   rP   rR   c                V    [        U 5      n US:X  a	  [        U    $ [        [        S.U    $ )Nrw   r*  )rK   _fill_methodsr   r#  )rJ   r{   s     r&   r  r  *  s.    v&FqyV$$5f==r(   c                    U c  g [        U SS9$ )NTrD   )rK   )rJ   s    r&   clean_reindex_fill_methodr.  1  s    ~V488r(   c                b  ^ [        U 5      m[        5       n[        5       nSU4S jjnUb1  US:X  a#  [        [        R                  " U 5      S   5      nOU" X5      nUbM  US:X  a  U$ [	        U" U SSS2   U5      5      n[        TS-
  [        R
                  " U5      -
  5      nUS:X  a  U$ X4-  $ )a  
Get indexers of values that won't be filled
because they exceed the limits.

Parameters
----------
invalid : np.ndarray[bool]
fw_limit : int or None
    forward limit to index
bw_limit : int or None
    backward limit to index

Returns
-------
set of indexers

Notes
-----
This is equivalent to the more readable, but slower

.. code-block:: python

    def _interp_limit(invalid, fw_limit, bw_limit):
        for x in np.where(invalid)[0]:
            if invalid[max(0, x - fw_limit):x + bw_limit + 1].all():
                yield x
c           	       > [        UT5      n[        XS-   5      R                  S5      n[        [        R
                  " U5      S   U-   5      [        [        R
                  " U S US-    ) R                  5       S:H  5      S   5      -  nU$ )Nrw   r   )min_rolling_windowr   r   r.   wherecumsum)r   r   windowedidxNs       r&   inner_interp_limit.<locals>.inner\  s    E1"7AI6::1="((8$Q'%/03HHw{++335:;A>4
 
 
r(   Nr   rz   rw   )r   int)r!   r   r.   r3  listr   )r   fw_limitbw_limitf_idxb_idxr8  	b_idx_invr7  s          @r&   r   r   7  s    B 	GAEEEE q=)!,-E',Eq= LU74R4=(;<IA

9 556E1}=r(   c                    U R                   SS U R                   S   U-
  S-   U4-   nU R                  U R                  S   4-   n[        R                  R                  R                  XUS9$ )zy
[True, True, False, True, False], 2 ->

[
    [True,  True],
    [True, False],
    [False, True],
    [True, False],
]
Nrz   rw   )r4   strides)r4   rB  r.   r   stride_tricks
as_strided)awindowr4   rB  s       r&   r2  r2  x  sh     GGCRLAGGBK&014f==Eii199R=**G66**17*KKr(   )r$   npt.NDArray[np.bool_]r%   r:  )r:   r   r   rG  )rJ   z,Literal['ffill', 'pad', 'bfill', 'backfill']rE   zLiteral[False]r   Literal['pad', 'backfill'])rJ   7Literal['ffill', 'pad', 'bfill', 'backfill', 'nearest']rE   zLiteral[True]r   %Literal['pad', 'backfill', 'nearest'])rJ   rI  rE   r5   r   rJ  )rJ   rT   r[   r   r   rT   )r}   rT   r~   rG  r   r  )r   rT   r   z&Literal['forward', 'backward', 'both'])r   
str | Noner   r  )r   z-Literal['backward', 'forward', 'both'] | NonerJ   rT   r   z&Literal['backward', 'forward', 'both'])r[   r   r   r   )rY   Nr   NNN)r   r   r[   r   ry   r   rJ   rT   r   r  r   rT   r   rK  r   
Any | Noner   r   )r[   r   rJ   rT   r   r   )rY   Nr   NNFNN)r   r   r   r   rJ   rT   r   r  r   rT   r   r  r   rL  r   r5   rk   r  r   r   )NFN)
rA   r   r   r   r   r   rJ   rT   r   r5   )Nr   F)
r   r   r   r   rA   r   r   int | list[int] | Noner   r5   )r   r   )
r   r   r   r   rA   r   r   rM  ry   r   )r   z
not-a-knotN)
r   r   r   r   rA   r   ry   r   r   zstr | tuple[Any, Any])
r\   r   rJ   rH  r   r  r   zLiteral['inside', 'outside']r   r   )rP   r   NN)r\   r   rJ   rH  ry   r   r   r  r   r  r   r   rG   )r$   npt.NDArray[np.bool_] | Noner   rG  )r   r   r   r   r  )
r\   r   r   r  r   r  r$   rN  r   z(tuple[np.ndarray, npt.NDArray[np.bool_]])r\   r   r   r  r   r  r$   rN  )r   r  r   r  r$   rN  )r$   rG  r   zLiteral['outside', 'inside']r   r   r  )r{   r:  )r   zReindexMethod | None)r   rG  r<  r  r=  r  )rE  rG  rF  r:  r   rG  )K__doc__
__future__r   	functoolsr   typingr   r   r   r   r	   numpyr.   pandas._libsr
   r   r   pandas._typingr   r   r   r   r   pandas.compat._optionalr   pandas.core.dtypes.castr   pandas.core.dtypes.commonr   r   r   r   r   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.missingr   r   r   r   r   r'   rC   rK   rm   rn   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r  r   r#  r  r  r,  r  r.  r   r2  rH   r(   r&   <module>r[     s   #    
  ? 4  6  FR 
 %(8 "  	 
 
C ! +	 
  C  +	4 3

$&#L+BLO+*F $!!	C*
C*C* C* 	C*
 C* C* C* C* 
C*L2 $6:!	ooo o 	o
 o 4o o o o 
on 
DDD D 	D DV "#/// /
 
 / /l #$... . 
 	.
 .j %1SSS S 	S
 #Sl2!2!&2! 2! -	2!
 
2!n */6:)6)6&)6 )6 	)6
 4)6 
)6Z 26.6  6:)-	


 4
 '	

 .
 
  6:)-	


 4
 '	

 .
 
  6:)-	 4 '	 $  6:)-	 4 '	 $'
'-I'	'4
-I	>  \:>9>">.8>DN>BLr(   