
    m*iO                         S SK rS SKrS SKJr  S SKJr  S SKJr  S SK	J
s  Jr  S SKJrJrJrJr  S SKJr   " S S5      rg)    N)using_string_dtype)WARNING_CHECK_DISABLED)ChainedAssignmentError)	DataFrameNaTSeries
date_rangec                      \ rS rSrS rS rS rS r\R                  R                  \" 5       SS9S 5       rS	 rS
 rS rS rS rS rS rS r\R                  R+                  S\R,                  " SSSS9\R,                  " SSSS9\R,                  " SSSS9/5      S 5       rS r\R                  R+                  SS\R,                  " S\R4                  " S 5      S!9/5      S" 5       rS# rS$ rS% rS& rS' r S( r!\R                  R+                  SS)S*/5      S+ 5       r"\R                  R+                  S,SS/5      \R                  R+                  S-/ S.Q5      S/ 5       5       r#S0 r$S1 r%\R                  R+                  S2S3S4\R,                  " S5\R4                  " S65      S!9\R,                  " S7\R4                  " S65      S!9/5      S8 5       r&\R                  R+                  S2/ S9Q5      S: 5       r'S;r(g<)=TestDataFrameInterpolate   c                    [        [        S5      [        S5      [        S5      /5      nUR                  R                  S:X  d   eUR                  5       n[        US   US   S-  US   /5      n[        R                  " X#5        UR                  5       nUR                  5       nUR                  5       n[        R                  " X#5        g )Nz1+1jnanz2+2jcr         ?   )
r   complexfloatdtypekindinterpolatetmassert_series_equalto_frameassert_frame_equal)selfserresexpecteddfs        k/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pandas/tests/frame/methods/test_interpolate.pytest_interpolate_complex1TestDataFrameInterpolate.test_interpolate_complex   s    gfouU|WV_EFyy~~$$$oo3q63q6C<Q89
s-\\^nn$$&
c,    c                    [        [        SSS95      nUR                  5       n[        US'   U" U5      R	                  5       nU" U5      n[
        R                  " XE5        UR                  R                  S5      nU" U5      R	                  5       nU" UR                  R                  S5      5      n[
        R                  " Xx5        X3S   -
  n	U" U	5      R	                  5       n
U" X"S   -
  5      n[
        R                  " X5        g )Nz
2012-01-01   )periodsr   z
US/Pacificr   )	r   r	   copyr   r   r   assert_equaldttz_localize)r   frame_or_seriesorigr   r   r   ser_tzres_tzexpected_tzser_tdres_tdexpected_tds               r    $test_interpolate_datetimelike_values=TestDataFrameInterpolate.test_interpolate_datetimelike_values"   s    jq9:iikAc"..0"4(
& ##L1 (446%dgg&9&9,&GH
, 1v (446%d!Wn5
,r#   c                    U(       a7  U[         L a.  [        R                  R                  SS9nUR	                  U5        U" S[
        R                  S/5      nUR                  nUR                  SS9  U" / SQ5      n[        R                  " XW5        [
        R                  " XeR                  5      (       d   eUR                  5       S   S:X  d   eg )	Nz'.values-based in-place check is invalidreason   r   Tinplace)r8   r   r   r   )r   pytestmarkxfailapplymarkernpr   valuesr   r   r(   shares_memorysqueeze)r   r+   using_array_managerrequestr<   objr,   r   s           r    test_interpolate_inplace1TestDataFrameInterpolate.test_interpolate_inplace8   s    ?i#?;;$$,U$VD%q"&&!n-zz%";/
& jj1111||~a C'''r#   c                 4   [        SS[        R                  S/SSS[        R                  // SQ[        S5      S.5      n[        / SQ/ S	Q/ SQ[        S5      S.5      nU(       aD  U(       a  S
OSnSU S3n[        R
                  " [        US9   UR                  5         S S S 5        g Sn[        R                  " [        US9   UR                  5       nS S S 5        [        R                  " WU5        US   R                  nUS   R                  n	U(       aU  [        R                  " XS   R                  5      (       d   e[        R                  " XS   R                  5      (       d   eOT[        R                  " XS   R                  5      (       a   e[        R                  " XS   R                  5      (       a   e[        R                  " [        US9   UR                  SS9n
S S S 5        W
b   e[        R                  " X45        [        R                  " US   R                  U5      (       d   e[        R                  " US   R                  U	5      (       d   eg ! , (       d  f       g = f! , (       d  f       GN= f! , (       d  f       N= f)Nr8   r      	   r8   r      r%   abcdABCD      ?       @      @      @)rT   rW         "@rX   strobjectz[Cc]annot interpolate with z dtypematch'DataFrame.interpolate with object dtyperQ   rR   Tr9   )r   r?   r   listr;   raises	TypeErrorr   r   assert_produces_warningFutureWarningr   _valuesr@   rA   )r   using_copy_on_writeusing_infer_stringr   r   r   msgresultcvaluesdvaluesr   s              r    test_interp_basic*TestDataFrameInterpolate.test_interp_basicI   s   BFFA&Arvv&!&\	
 ))!&\	
 /EXE/wf=Cy4  57''SA^^%F B
fh/ S'//S'..##GC[-@-@AAAA##GC[-@-@AAAA''1D1DEEEE''1D1DEEEE''SA....C B{{
b+ 39999399995 54 BA BAs$   I&I7J	&
I47
J	
Jz#interpolate doesn't work for stringr6   c                    [        SS[        R                  S/SSS[        R                  // SQ[        S5      S.5      nSnU(       d  [        OS n[
        R                  " XCS	9   UR                  S
5      R                  5       nS S S 5        UR                  S
5      nSUR                  S'   SUR                  S'   [
        R                  " WU5        g ! , (       d  f       NU= f)Nr8   r   rI   rJ   rK   rM   rN   r]   r[   rQ   rL   rL   rO   )r%   rP   )r   r?   r   r^   rb   r   ra   	set_indexr   locr   )r   re   r   rf   warningrg   r   s          r    &test_interp_basic_with_non_range_index?TestDataFrameInterpolate.test_interp_basic_with_non_range_indexy   s     BFFA&Arvv&!&\	
 8'9-t'';\\#&224F <<<$ V V
fh/ <;s   % C
C"c                 t    [        5       nUR                  5       nX!Ld   eUn[        R                  " X#5        g )N)r   r   r   r   r   r   rg   r   s       r    test_interp_empty*TestDataFrameInterpolate.test_interp_empty   s4    [!
f/r#   c                     [        SS[        R                  S/SSS[        R                  // SQS.5      nSn[        R                  " [
        US9   UR                  S	S
9  S S S 5        g ! , (       d  f       g = f)Nr8   r   rI   rJ   rK   rO   rP   rQ   a  method must be one of \['linear', 'time', 'index', 'values', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', 'krogh', 'spline', 'polynomial', 'from_derivatives', 'piecewise_polynomial', 'pchip', 'akima', 'cubicspline'\]. Got 'not_a_method' instead.r[   not_a_methodmethod)r   r?   r   r;   r_   
ValueErrorr   r   r   rf   s      r    test_interp_bad_method/TestDataFrameInterpolate.test_interp_bad_method   sh    BFFA&Arvv&!
< 	 ]]:S1NN.N1 211s   A**
A8c                    [        SS[        R                  S/SSS[        R                  // SQ[        S5      S	.5      nUS
   R	                  5       n[        / SQS
S9n[        R                  " X#5        Sn[        R                  " [        US9   US
   R	                  SS9nS S S 5        [        / SQS
S9n[        R                  " X#5        g ! , (       d  f       N1= f)NrT   rU   rW   r8   rI   rJ   rK   rM   rN   rO   rS   )name:The 'downcast' keyword in Series.interpolate is deprecatedr[   inferdowncastr8   r   rL   rI   )
r   r?   r   r^   r   r   r   r   ra   rb   )r   r   rg   r   rf   s        r    test_interp_combo*TestDataFrameInterpolate.test_interp_combo   s    3,Arvv&!&\	
 C$$&.S9
v0J''SAW(('(:F B,S1
v0 BAs   C
Cc                 h   [        SS[        R                  S/SSS[        R                  // SQ[        S5      S	.5      nS
nSnSn[        R
                  " [        US9   [        R                  " [        US9   UR                  SS9  S S S 5        S S S 5        [        R
                  " [        US9   [        R                  " [        US9   US   R                  SS9  S S S 5        S S S 5        g ! , (       d  f       Nm= f! , (       d  f       Nv= f! , (       d  f       N9= f! , (       d  f       g = f)NrT   rU   rW   r8   rI   rJ   rK   rM   rN   z'downcast must be either None or 'infer'=The 'downcast' keyword in DataFrame.interpolate is deprecatedr   r[   int64r   rO   )r   r?   r   r^   r;   r_   r|   r   ra   rb   r   )r   r   rf   msg2msg3s        r     test_inerpolate_invalid_downcast9TestDataFrameInterpolate.test_inerpolate_invalid_downcast   s    3,Arvv&!&\	
 8NK]]:S1++MF0 G 2 ]]:S1++MF3##W#5 G 21 GF 21 GF 21sH   D9C0	D2D#DD#0
C>	:D
D
D 	D##
D1c                    [        SS[        R                  S/[        R                  SSS/S.5      nUR                  S5      nSn[        R
                  " [        US9   UR                  S	S
9  S S S 5        g ! , (       d  f       g = f)Nr8   r   rI   rL   rO   rP   rO   zkInterpolation with NaNs in the index has not been implemented. Try filling those NaNs before interpolating.r[   r@   rz   )r   r?   r   rn   r;   r_   NotImplementedErrorr   r}   s      r    test_interp_nan_idx,TestDataFrameInterpolate.test_interp_nan_idx   sn    aBFFA.bffaA5FGH\\#; 	 ]].c:NN(N+ ;::s   A88
Bc           	         [         R                  " S5        [        SS[        R                  SS[        R                  S// SQS.5      nUR                  S	5      nUR                  5       nUR                  S
SS9nSUR                  S'   SUR                  S'   [        R                  " X25        UR                  SS9nSUR                  S'   SUR                  S'   [        R                  " X25        UR                  SS9nSUR                  S'   SUR                  S'   [        R                  " X2SS9  UR                  SS9nSUR                  S'   SUR                  S'   [        R                  " X25        UR                  SS9nSUR                  S'   SUR                  S'   [        R                  " X25        UR                  SS9nSUR                  S'   SUR                  S'   [        R                  " X2SS9  g )Nscipyr8   r   rI   r%      r8   r   rL   r%            rO   rQ   rQ   
polynomialr{   ordergUUU@rm   gu:@)r   rO   cubicrz   gv:@gb+hZ@nearestF)check_dtype	quadraticg^r@g!g@slineargX ;@zerorU   )r;   importorskipr   r?   r   rn   r'   r   ro   r   r   r   r   r   rg   s       r    test_interp_various,TestDataFrameInterpolate.test_interp_various   s   G$aArvvq18OP
 \\#779|1=)V *W
f/w/)V *W
f/y1 V !W
fEB{3)V *W
f/y1)V *W
f/v."V !W
fEBr#   c           	      ,   [         R                  " S5        [        SS[        R                  SS[        R                  S// SQS.5      nUR                  S	S
9nUR                  5       nSUR                  S'   SUR                  S'   [        R                  " X#5        Sn[        R                  " [        US9   UR                  S	SS9nS S S 5        [        R                  " X#R                  [        R                  5      5        UR                  SS
9nUR                  5       nUS   US'   [        R                  " X%5        UR                  SS
9nSUR                  S'   SUR                  S'   [        R                  " X#5        g ! , (       d  f       N= f)Nr   r8   r   rI   r%   r   r   r   barycentricrz   rL   )r   rO      )r%   rO   r   r[   r   )r{   r   kroghrO   pchip      @)r;   r   r   r?   r   r   r'   ro   r   r   ra   rb   astyper   )r   r   rg   r   rf   	expectedks         r    test_interp_alt_scipy.TestDataFrameInterpolate.test_interp_alt_scipy  sC   G$aArvvq18OP
 }5779 V V
f/M''SA^^=7^KF B
foobhh&?@w/GGI	!#	#
f0w/ V"V
f/ BAs   8F
Fc           	      ~   [        SS[        R                  S/SSS[        R                  /[        R                  SSS/S[        R                  SS// SQS	.5      nUR                  SS
9nUR	                  5       nSUR
                  S'   SUR
                  S'   SUR
                  S'   US   R                  [        R                  5      US'   [        R                  " X#5        UR                  SSS9n[        R                  " X#5        UR                  SS
9nUR                  5       n[        R                  " X#5        g )Nr8   r   rI   rL   r%   r   r   r   )r   r8   r   rL   rI   axis)rL   r8   )r   r   )r8   rL   r@   r   r{   r   )
r   r?   r   r   r'   ro   r   float64r   r   rt   s       r    test_interp_rowwise,TestDataFrameInterpolate.test_interp_rowwise  s   q"&&!$q!RVV$FFAq!$rvvq!$
 Q'779TTTqk((4
f/Qx8
f/Q'>>#
f/r#   zaxis_name, axis_numberrowsr   rows_0)idindexindex_0columnsr8   	columns_1c                     S[         R                  S/S[         R                  S// SQS.n[        U[         R                  S9nUR	                  USS	9nUR	                  USS	9n[
        R                  " XV5        g )
Nr   r   r8   r   )r   r%   r   )r   r8   r   r   linearr   )r?   r   r   r   r   r   r   )r   	axis_nameaxis_numberdatar   rg   r   s          r    test_interp_axis_names/TestDataFrameInterpolate.test_interp_axis_names7  sf     rvvq>q"&&!nCt2::.Yx@>>{8>D
f/r#   c                     [        SSS[        R                  SS[        R                  [        R                  S/	/ SQS.5      nUR                  SS	9  g )
Nr         ?rT   rI   r   @   )	r8   r   rL   rI   rL   r   r8   r   )r   r8   r   )r   r?   r   r   )r   r   s     r    test_rowwise_alt)TestDataFrameInterpolate.test_rowwise_altH  sF    sCArvvrvvrB/
 	Ar#   check_scipyFTr   )marksc                    [        [        R                  [        R                  SSS/[        R                  SS[        R                  S/S.5      nUR                  5       nUR	                  5       nSUR
                  S	'   [        R                  " X45        U(       a'  UR                  S
SS9n[        R                  " X45        g g )Nr   g      ?r   g      r   g      )rL   rP   r   r8   r   )r   r?   r   r   r'   ro   r   r   )r   r   r   rg   r   s        r    test_interp_leading_nans1TestDataFrameInterpolate.test_interp_leading_nansR  s     662663a0D"&&RT7UV
 !779$V
f/^^<q^AF!!&3 r#   c           	      \   [        SS[        R                  S// SQ[        R                  SSS/[        R                  [        R                  SS// SQS	.5      nS
n[        R                  " [
        US9   UR                  S5      R                  US9  S S S 5        g ! , (       d  f       g = f)Nr8   r   rI   )abr   dr%   r   rJ   r   )rO   rP   rQ   rR   EvCannot interpolate with all object-dtype columns in the DataFrame. Try setting at least one column to a numeric dtype.r[   rZ   r   )r   r?   r   r;   r_   r`   r   r   )r   r   r   rf   s       r    test_interp_raise_on_only_mixed8TestDataFrameInterpolate.test_interp_raise_on_only_mixedb  s    BFFA&)ffaA&ffbffa+!
) 	
 ]]9C0IIh+++6 100s   5B
B+c                     [        / SQ/ SQS.SS9nSn[        R                  " [        US9   UR	                  5         S S S 5        g ! , (       d  f       g = f)N)r8   r   rL   )rI   r%   r   r   rZ   r   r   r[   )r   r;   r_   r`   r   r}   s      r    %test_interp_raise_on_all_object_dtype>TestDataFrameInterpolate.test_interp_raise_on_all_object_dtypet  sC    YY7xH) 	
 ]]9C0NN 100s   A
Ac                 (   [        SSS[        R                  S/05      n[        S/ SQ05      nUR                  5       nUR                  5       nU(       aL  [        R
                  " 5          US   R                  SS9nS S S 5        Wb   e[        R                  " XT5        O\[        R                  " [        (       d  [        OS SS	9   US   R                  SS9nS S S 5        Wb   e[        R                  " XS5        UR                  5       nS
nU(       aW  [        R                  " [        [        4US	9   US   R                  SSS9nS S S 5        Ub   e[        R                  " XT5        g [        R                  " [        US	9   US   R                  SSS9nS S S 5        Ub   e[        R                  " XSR                  S5      5        g ! , (       d  f       GNW= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       Nn= f)Nr   rT   rU   rW   rS   Tr9   zinplace methodr[   r   r   )r:   r   r   )r   r?   r   r'   r   raises_chained_assignment_errorr   r   ra   r   rb   r   r   )r   rd   r   r   expected_cowrg   return_valuerf   s           r    test_interp_inplace,TestDataFrameInterpolate.test_interp_inplace  s   c3456c#789wwy335%c{66t6D 6'''!!&7++%;%;&  &c{66t6D	
  '''!!&3J++ 67s  &c{66tg6V  '''!!&7++ME%c{66tg6V F'''!!&//'*BC7 65
   FEs0   +GG 6G2H
G 
G/2
H 
Hc                     [        / SQ[        R                  SSS// SQS.5      nUR                  SSS	S
9nUR                  SSSS
9nUb   e[        R
                  " X5        g )NrS   rU   rV   rW   )rL   r   r   r   )r   r   r   r   r8   F)r{   r   r:   T)r   r?   r   r   r   r   )r   rg   r   r   s       r    test_interp_inplace_row0TestDataFrameInterpolate.test_interp_inplace_row  sm    &bffc3-D<X
 %%XAu%M))4)P###
f/r#   c           
         [        SS[        R                  S// SQSS[        R                  S// SQS	.5      n[        [        R                  " / SQS
S9[        R                  " / SQSS9[        R                  " / SQS
S9[        R                  " / SQS
S9S	.5      nSn[        R
                  " [        US9   UR                  S S9nS S S 5        [        R                  " WU5        [        R
                  " [        US9   USS/   R                  S S9nS S S 5        [        R                  " XASS/   5        g ! , (       d  f       Nw= f! , (       d  f       N;= f)Nr8   r   rI   r   rT   rU   rW   rS   rN   r   r   r   )rT   rU   rL   rW   r   r[   r   rP   rR   )	r   r?   r   arrayr   ra   rb   r   r   )r   r   r   rf   rg   s        r    test_interp_ignore_all_good4TestDataFrameInterpolate.test_interp_ignore_all_good  s   BFFA&!3,)	
 XXl)<XXl':XX0	BXX2)D	
 N''SA^^T^2F B
fh/ ''SAc
^///>F B
f#sn5 BA
 BAs   8D9 E
9
E

Ec                 0   Sn[        SUS9n[        R                  R                  S5      R                  X45      n[        R                  X3S:  '   [        X"US9nUR                  SSS	9nUR                  SSS
S9nUb   e[        R                  " XT5        g )Nr%   z
2014-01-01)startr&   r   r   )r   r   r   r   timer   T)r   r{   r:   )	r	   r?   randomdefault_rngr   r   r   r   r   )r   r&   idxr   r   rg   r   s          r    test_interp_time_inplace_axis6TestDataFrameInterpolate.test_interp_time_inplace_axis  s    |W=yy$$Q'../AB66CZ3$?%%1V%<++64+P###
f/r#   )r   r   )r   r8   c                 T   [         R                  " SSS5      n[         R                  " U5      n[        [         R                  " US5      [         R
                  " S5      US9R                  US-  S9nUR                  S	US
9nUR                  S	US
9n[        R                  " Xg5        g )Nr   d   i  )
   r8   r   )r   r   r   gGz?)r   r   r{   r   )
r?   linspacesinr   tilearangereindexr   r   r   )r   r   r   xyr   rg   r   s           r    test_interp_string_axis0TestDataFrameInterpolate.test_interp_string_axis  s     KK3%FF1IG$BIIbM1

'!e)'
$ 	 xi@>>>D
f/r#   
multiblockr{   )ffillbfillpadc           
      *   U(       a  US;   a  [         R                  " U5        [        SSSS[        R                  S/SSS[        R                  SS	/SSS
[        R                  [        R                  S/S.5      nU(       a  [        R                  US'   SUS'   US:w  a  UOSn[        Xg5      " US9nSU S3n	[        R                  " [        U	S9   UR                  XBS9n
S S S 5        [        R                  " W
U5        g ! , (       d  f       N&= f)N)r8   r   rT   rU   rV   rW   g      @r   g       @g      $@rX   g      >@rx   rR   r   r  r  r   z"DataFrame.interpolate with method=z is deprecatedr[   r   )td&mark_array_manager_not_yet_implementedr   r?   r   getattrr   ra   rb   r   r   )r   rD   r   r  r{   rC   r   method2r   rf   rg   s              r    test_interp_fillna_methods3TestDataFrameInterpolate.test_interp_fillna_methods  s     4>#955g>3S"&&#63RVVS$73RVVRVVT:
 ffBsGBsG"eO&2'T226(.I''SA^^6^=F B
fh/ BAs   D
Dc                     [        5       nUR                  5       nUR                  SS9nUb   e[        R                  " X5        g )NTr9   r   r'   r   r   r   r   s       r    test_interpolate_empty_df2TestDataFrameInterpolate.test_interpolate_empty_df  s<    [779-~~
b+r#   c                     [        S/ SQ0US9nUR                  5       nUR                  SS9n[        S/ SQ0SS9n[        R                  " XE5        [        R                  " X#5        g )Nr   r8   NNNrL   r   r   limitr8   r   rU   NrL   Float64r  )r   any_int_ea_dtyper   r,   rg   r   s         r    test_interpolate_ea,TestDataFrameInterpolate.test_interpolate_ea  s^    56>NOwwya(c#9:)L
f/
b'r#   r   r  Float32zfloat32[pyarrow]pyarrowfloat64[pyarrow]c                     [        S/ SQ0US9nUR                  5       nUR                  SS9n[        S/ SQ0US9n[        R                  " XE5        [        R                  " X#5        g )Nr   r  r   r   r  r  r  )r   r   r   r,   rg   r   s         r    test_interpolate_ea_float2TestDataFrameInterpolate.test_interpolate_ea_float  s_     56eDwwya(c#9:%H
f/
b'r#   )r   uint64int32int16int8uint32uint16uint8c                     [         R                  " S5        [        S/ SQ0US-   S9nUR                  SS9n[        S/ SQ0S	S9n[        R
                  " X45        g )
Nr  r   r  z	[pyarrow]r   r   r  r  r  )r;   r   r   r   r   r   )r   r   r   rg   r   s        r    test_interpolate_arrow/TestDataFrameInterpolate.test_interpolate_arrow"  sZ     	I&56ek>QRa(c#9:BTU
f/r#    N))__name__
__module____qualname____firstlineno__r!   r3   rF   rj   r;   r<   r=   r   rq   ru   r~   r   r   r   r   r   r   parametrizeparamr   r   r	  
skip_if_nor   r   r   r   r   r   r   r  r  r  r  r   r*  __static_attributes__r,  r#   r    r   r      s7   --,(".:` [[%J  00&02$1(6*,%CN0602 [[ LLx0LL!	2LLA+6	
00 [[v||Dg8NOP447$	"DH06:0 [[5n7UV	0 W	0 [[\D%=9[[X'@A0 B :04,( [[LL+2==3KLLL+2==3KL		
(( [[R0	0r#   r   )numpyr?   r;   pandas._configr   pandas.compatr   pandas.errorsr   pandas.util._test_decoratorsutil_test_decoratorsr	  pandasr   r   r   r	   pandas._testing_testingr   r   r,  r#   r    <module>r?     s5      - 0 0 ) )  Y0 Y0r#   