
    MhN                     v    S SK rS SK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_pyarrow_string_dtype)ChainedAssignmentError)	DataFrameNaTSeries
date_rangec                   2   \ rS rSrS rS rS r\R                  R                  \
" 5       SS9S 5       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        ]/var/www/html/env/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)r7   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_inplace7   s    ?i#?;;$$,U$VD%q"&&!n-zz%";/
& jj1111||~a C'''r"   z#interpolate doesn't work for stringr5   c                 |   [        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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                  " XeS   R                  5      (       d   e[        R                  " XuS   R                  5      (       d   eOT[        R                  " XeS   R                  5      (       a   e[        R                  " XuS   R                  5      (       a   e[        R
                  " [        US9   UR                  SS9nS S S 5        Wb   e[        R                  " X#5        [        R                  " US   R                  U5      (       d   e[        R                  " US   R                  U5      (       d   eg ! , (       d  f       GN= f! , (       d  f       N= f)Nr7   r      	   r7   r      r$   abcdABCD      ?       @      @      @)rS   rV         "@rW   'DataFrame.interpolate with object dtypematchrP   rQ   Tr8   )r   r>   r   listr   assert_produces_warningFutureWarningr   r   _valuesr?   r@   )	r   using_copy_on_writer   r   msgresultcvaluesdvaluesr   s	            r   test_interp_basic*TestDataFrameInterpolate.test_interp_basicH   s    BFFA&Arvv&!&\	
 ))!&\	
 8''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9+ BA BAs   :HH-
H*-
H;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)Nr7   r   rH   rI   rJ   rL   rM   rX   rY   rP   rK   rK   rN   )r$   rO   )r   r>   r   r[   r]   r   r\   	set_indexr   locr   )r   using_infer_stringr   r`   warningra   r   s          r   &test_interp_basic_with_non_range_index?TestDataFrameInterpolate.test_interp_basic_with_non_range_indext   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   ra   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)Nr7   r   rH   rI   rJ   rN   rO   rP   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.rY   not_a_methodmethod)r   r>   r   r:   raises
ValueErrorr   r   r   r`   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)NrS   rT   rV   r7   rH   rI   rJ   rL   rM   rN   rR   )name:The 'downcast' keyword in Series.interpolate is deprecatedrY   inferdowncastr7   r   rK   rH   )
r   r>   r   r[   r   r   r   r   r\   r]   )r   r   ra   r   r`   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)NrS   rT   rV   r7   rH   rI   rJ   rL   rM   z'downcast must be either None or 'infer'=The 'downcast' keyword in DataFrame.interpolate is deprecatedr~   rY   int64r   rN   )r   r>   r   r[   r:   rw   rx   r   r\   r]   r   )r   r   r`   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)Nr7   r   rH   rK   rN   rO   rN   zkInterpolation with NaNs in the index has not been implemented. Try filling those NaNs before interpolating.rY   r?   ru   )r   r>   r   rh   r:   rw   NotImplementedErrorr   ry   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scipyr7   r   rH   r$      r7   r   rK   r$            rN   rP   rP   
polynomialrv   ordergUUU@rg   gu:@)r   rN   cubicru   gv:@gb+hZ@nearestF)check_dtype	quadraticg^r@g!g@slineargX ;@zerorT   )r:   importorskipr   r>   r   rh   r&   r   ri   r   r   r   r   r   ra   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   r7   r   rH   r$   r   r   r   barycentricru   rK   )r   rN      )r$   rN   r   rY   r   )rv   r   kroghrN   pchip      @)r:   r   r   r>   r   r   r&   ri   r   r   r\   r]   astyper   )r   r   ra   r   r`   	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 )Nr7   r   rH   rK   r$   r   r   r   )r   r7   r   rK   rH   axis)rK   r7   )r   r   )r7   rK   r?   r   rv   r   )
r   r>   r   r   r&   ri   r   float64r   r   ro   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columnsr7   	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   r7   r   )r   r$   r   )r   r7   r   r   linearr   )r>   r   r   r   r   r   r   )r   	axis_nameaxis_numberdatar   ra   r   s          r   test_interp_axis_names/TestDataFrameInterpolate.test_interp_axis_names2  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         ?rS   rH   r   @   )	r7   r   rK   rH   rK   r   r7   r   )r   r7   r   )r   r>   r   r   )r   r   s     r   test_rowwise_alt)TestDataFrameInterpolate.test_rowwise_altC  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      )rK   rO   r   r7   r   )r   r>   r   r   r&   ri   r   r   )r   r   r   ra   r   s        r   test_interp_leading_nans1TestDataFrameInterpolate.test_interp_leading_nansM  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)Nr7   r   rH   )abr   dr$   r   rI   r   )rN   rO   rP   rQ   EvCannot interpolate with all object-dtype columns in the DataFrame. Try setting at least one column to a numeric dtype.rY   objectr   )r   r>   r   r:   rw   	TypeErrorr   r   )r   r   r   r`   s       r   test_interp_raise_on_only_mixed8TestDataFrameInterpolate.test_interp_raise_on_only_mixed]  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)r7   r   rK   )rH   r$   r   r   r   r   r   rY   )r   r:   rw   r   r   ry   s      r   %test_interp_raise_on_all_object_dtype>TestDataFrameInterpolate.test_interp_raise_on_all_object_dtypeo  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        OO[        R                  " [        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NJ= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       Nn= f)Nr   rS   rT   rV   rR   Tr8   zinplace methodrY   r~   r   )r9   r   r   )r   r>   r   r&   r   raises_chained_assignment_errorr   r   r\   r]   r   r   )r   r_   r   r   expected_cowra   return_valuer`   s           r   test_interp_inplace,TestDataFrameInterpolate.test_interp_inplacez  s   c3456c#789wwy335%c{66t6D 6'''!!&7++MAQR%c{66t6D S'''!!&3J++ 67s  &c{66tg6V  '''!!&7++ME%c{66tg6V F'''!!&//'*BC1 65
 SR  FEs0   +G;G)G%:G6
G
G"%
G36
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 )NrR   rT   rU   rV   )rK   r   r   r   )r   r   r   r   r7   F)rv   r   r9   T)r   r>   r   r   r   r   )r   ra   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)Nr7   r   rH   r   rS   rT   rV   rR   rM   r   r   r   )rS   rT   rK   rV   r   rY   r   rO   rQ   )	r   r>   r   arrayr   r\   r]   r   r   )r   r   r   r`   ra   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   rv   r9   )	r   r>   randomdefault_rngr   r   r   r   r   )r   r%   idxr   r   ra   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   r7   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  )
   r7   r   )r   r   r   gGz?)r   r   rv   r   )
r>   linspacesinr   tilearangereindexr   r   r   )r   r   r   xyr   ra   r   s           r   test_interp_string_axis0TestDataFrameInterpolate.test_interp_string_axis  s     KK3%FF1IG$BIIbM1

'!e)'
$ 	 xi@>>>D
f/r"   
multiblockrv   )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)r7   r   rS   rT   rU   rV   g      @r   g       @g      $@rW   g      >@rs   rQ   r   r  r  r   z"DataFrame.interpolate with method=z is deprecatedrY   r   )td&mark_array_manager_not_yet_implementedr   r>   r   getattrr   r\   r]   r   r   )r   rC   r   r  rv   rB   r   method2r   r`   ra   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 )NTr8   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   r7   NNNrK   r   r   limitr7   r   rT   NrK   Float64r  )r   any_int_ea_dtyper   r+   ra   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+   ra   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   ra   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    r2   rE   r:   r;   r<   r   rd   rl   rp   rz   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
      sc   --,(" [["$-R  ':':R [["$-R  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B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.errorsr   pandas.util._test_decoratorsutil_test_decoratorsr  pandasr   r   r   r   pandas._testing_testingr   r
   r*  r"   r   <module>r<     s2      5 0 ) )  R0 R0r"   