
    bMhۅ                         d dl Zd dlZd dlmc mZ d dlZd dlm	Z	m
Z
mZmZmZ d dlmZ  ej        g d          d             Z ej        g d          d             Z G d d	          ZdS )
    N)Index
MultiIndexSeries
date_rangeisna)linearindexvaluesnearestslinearzero	quadraticcubicbarycentrickrogh
polynomialsplinepiecewise_polynomialfrom_derivativespchipakimacubicspline)paramsc                 ,    | j         }|dv rddini }||fS )a	  Fixture that returns an (method name, required kwargs) pair.

    This fixture does not include method 'time' as a parameterization; that
    method requires a Series with a DatetimeIndex, and is generally tested
    separately from these non-temporal methods.
    r   r   order   paramrequestmethodkwargss      l/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/series/methods/test_interpolate.pynontemporal_methodr%      s-    8 ]F#'???gq\\RF6>    )r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                 ,    | j         }|dv rddini }||fS )zFixture that returns a (method name, required kwargs) pair to
    be tested for various Index types.

    This fixture does not include methods - 'time', 'index', 'nearest',
    'values' as a parameterization
    r   r   r   r   r    s      r$   interp_methods_indr(   2   s-    2 ]F#'???gq\\RF6>r&   c                      e Zd Zej                            d          d             Zd Zd Zd Z	d Z
d Zd	 Zd
 Zej                            di  ej        ddd ej        d                    g          d             Zd Zd Zej                            di  ej        ddd ej        d                    g          d             Zd Zd Zd Zd Zd Zej                            dddg          d             Zd Zej                            dd d!g          d"             Zd# Zd$ Zd% Z d& Z!d' Z"ej                            d(g d)          d*             Z#ej                            d+e$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.d.d.d.d/e$j%        e$j%        g	d0d1d2fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.d.e$j%        e$j%        d/e$j%        e$j%        g	d0d1dd3fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.e$j%        e$j%        e$j%        d/d/d/g	d0d4d2fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.e$j%        e$j%        e$j%        d/d/e$j%        g	d0d4dd3fe$j%        e$j%        e$j%        e$j%        e$j%        e$j%        e$j%        ge$j%        e$j%        e$j%        e$j%        e$j%        e$j%        e$j%        gd0d4dd3f e&d5           e&d5          d0d4dd3ff          d6             Z'ej                            d+e$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.d/d/d/d/e$j%        e$j%        g	d7d1d2fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        e$j%        d.e$j%        e$j%        d/d/e$j%        e$j%        g	d7d1dd3fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	d.d.d.e$j%        e$j%        e$j%        d/e$j%        e$j%        g	d7d4d2fe$j%        e$j%        d,e$j%        e$j%        e$j%        d-e$j%        e$j%        g	e$j%        d.d.e$j%        e$j%        e$j%        d/e$j%        e$j%        g	d7d4dd3ff          d8             Z(d9 Z)d: Z*d; Z+d< Z,ej                            d=d> ej        d? ej        d                    g          d@             Z-dA Z.ej                            dBdCd0g          dD             Z/dE Z0dF Z1ej                            dBddGg          dH             Z2ej                            dIddJddKe$j%        g          dL             Z3dM Z4dN Z5dO Z6dP Z7dQ Z8dR Z9dS Z:ej                            dTg dU e;j<        dVdWX           e;j=        ddWY          g          dZ             Z>d[ Z?ej                            d\d?g d]fd>g d^fg          d_             Z@d` ZAda ZBd S )bTestSeriesInterpolateDataz)EA.fillna does not handle 'linear' methodreasonc                 B   t          t          dd                    }|                                }t          j        |d<   |j                            d          }|                                }|j                            d          }t          j	        ||           d S )Nz
2012-01-01   )periods   D)
r   r   copypdNaTdt	to_periodinterpolatetmassert_series_equal)selforigserser_perres_perexpected_pers         r$   test_interpolate_period_valuesz8TestSeriesInterpolateData.test_interpolate_period_valuesQ   s    jq999::iikkA &""3''%%''w((--
w55555r&   c                 6   t          t          j        t          |          t                    |j                  }|                                }t          j        |dd<   |                    d          }t          j
        ||           t          d |j        D             |j                                      t                    }|                                }t          j        |dd<   |                    d          }t          j
        ||           d S )	Ndtyper.   
   r   r"   c                 6    g | ]}|                                 S  )	toordinal).0ds     r$   
<listcomp>z>TestSeriesInterpolateData.test_interpolate.<locals>.<listcomp>g   s     :::qQ[[]]:::r&   r	   time)r   nparangelenfloatr	   r2   nanr7   r8   r9   astype)r:   datetime_serieststs_copylinear_interpord_tsord_ts_copytime_interps           r$   test_interpolatez*TestSeriesInterpolateData.test_interpolate]   s    BIc/22%@@@/BWXX''))"++8+<<
}b111::O$9:::/BW
 
 

&-- 	 kkmmFAbD!--V-<<
{F33333r&   c                     t          dddt          j        g          }d}t          j        t
          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   r   r0   zGtime-weighted interpolation only works on Series.* with a DatetimeIndexmatchrM   rE   r   rN   rR   pytestraises
ValueErrorr7   )r:   non_tsmsgs      r$   /test_interpolate_time_raises_for_non_timeserieszITestSeriesInterpolateData.test_interpolate_time_raises_for_non_timeseriesp   s     Aq"&)**W]:S111 	. 	.f---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   AA#&A#c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          j
        d	d
         }t          j        ||           d S )NscipyrD            	      &@g     &@g      '@g     '@      (@g     (@g      )@g     )@      *@	      ?      ?      ?      ?       @      @      @      @      @rL   rr   rs   rt   rv   rw   rx   r   rE   r      )r`   importorskipr   r   r	   unionrS   rQ   reindexr7   locr8   r9   )r:   r<   expected	new_indexresults        r$   test_interpolate_cubicsplinez6TestSeriesInterpolateData.test_interpolate_cubicsplinex   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 Y''33=3IIMaPQcR
vx00000r&   c                    t          j        d           t          t          j        t          j                            d                              d                              }|j        	                    t          g d                                        t                    }|                    |                              d          }|j        dd	          d S )
Nrg   r0   d   )size)g     H@g     H@g     H@g      I@g     @I@g     `I@r   rE   1   3   )r`   r|   r   rN   sortrandomdefault_rnguniformr	   r}   r   rS   rQ   r~   r7   r   )r:   r<   r   interp_ss       r$   test_interpolate_pchipz0TestSeriesInterpolateData.test_interpolate_pchip   s    G$$$RWRY22155==3=GGHHII IOO:::;;
 

&-- 	 ;;y))55W5EERUr&   c                 
   t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    dd	          }t          j        |j        d	d
         |           d S )Nrg   rh   rl   rp   rL   rz   r   rE   r   r{   )	rm   rq   rq   rq   rn   rq   rq   rq   ro   )r"   derr`   r|   r   r   r	   r}   rS   rQ   r~   r7   r8   r9   r   r:   r<   r   r   r   s        r$   test_interpolate_akimaz0TestSeriesInterpolateData.test_interpolate_akima   s   G$$$%%%&& KKKIIIJJ
 
 
 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55W5EE
x|AaC0(;;; <<<IIIJJ
 
 
 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55W!5LL
x|AaC0(;;;;;r&   c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           d S )Nrg   rh   rl   rp   rL   rz   r   rE   r   r{   r   r   s        r$   %test_interpolate_piecewise_polynomialz?TestSeriesInterpolateData.test_interpolate_piecewise_polynomial   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55=S5TT
x|AaC0(;;;;;r&   c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           d S )Nrg   rh   rl   rp   rL   rz   r   rE   r   r{   r   r   s        r$   !test_interpolate_from_derivativesz;TestSeriesInterpolateData.test_interpolate_from_derivatives   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55=O5PP
x|AaC0(;;;;;r&   r#   r   r   r"   r   rg   )marksc                     t          t          j        t          j        g          }t          j         |j        di ||           t          g t                                                    }t          j         |j        di ||           d S )NrB   rG   )r   rN   rR   r8   r9   r7   object)r:   r#   ss      r$   test_interpolate_cornersz2TestSeriesInterpolateData.test_interpolate_corners   s     BFBF#$$
}q}66v66:::2V$$$0022
}q}66v66:::::r&   c                 T   t          t          j        t          j        t          j                            d                              d                              }t          j                            d                              d          |j        d d d<   |j        j	        
                    t                    }|                    d          }|                                }t          |j	                  }| }t          t          j        ||         ||         |j	        |                   |j        |                   }t!          j        ||         |           |                    d          }t!          j        ||           t!          j        ||         |           d S )	Nr0      rL   rD   r{   r	   rE   r
   )r   rN   rR   r   r   r   standard_normalr   r	   r
   rS   rQ   r7   r2   r   interpr8   r9   )r:   r   valsr   r   badgoodother_results           r$   test_interpolate_index_valuesz7TestSeriesInterpolateData.test_interpolate_index_values   sT   26)>)>q)A)A)H)H)L)L!M!MNNNY**1--==bAAccc
w~$$U++g..66888?##tId3idQXd^<<AGCL
 
 
 	vc{H555 }}H}55
|V444
|C0(;;;;;r&   c                    t          ddt          j        t          j        t          j        dg          }d}t          j        t
          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   r{   ri   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexr]   rM   rE   r_   r:   r   rd   s      r$   test_interpolate_non_tsz1TestSeriesInterpolateData.test_interpolate_non_ts   s    Aq"&"&"&"566# 	 ]:S111 	) 	)MMM(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A55A9<A9c                     t          ddt          j        dg          } |j        di |}t          g d          }t	          j        ||           d S )Nr   r   r{           rq   ru   ry   rG   r   rN   rR   r7   r8   r9   )r:   r#   r   r   r   s        r$   test_nan_interpolatez.TestSeriesInterpolateData.test_nan_interpolate   s`     Aq"&!$%%((((...//
vx00000r&   c                     t          ddt          j        dgg d          }|                                }t          g dg d          }t	          j        ||           d S )Nr   r0      )r   r{   r.   	   rL   )rq   ru   ry         @r   r:   r   r   r   s       r$   test_nan_irregular_indexz2TestSeriesInterpolateData.test_nan_irregular_index
  sf    Aq"&!$LLL999...lllCCC
vx00000r&   c                     t          dddt          j        gt          d                    }|                                }t          g dt          d                    }t          j        ||           d S )Nr   r   r0   abcdrL   )r   rq   ru   ru   )r   rN   rR   listr7   r8   r9   r   s       r$   test_nan_str_indexz,TestSeriesInterpolateData.test_nan_str_index  sj    Aq!RV$DLL999...d6llCCC
vx00000r&   c                     t          j        d           t          ddt          j        dgg d          }|                    d          }t          g d	g d          }t          j        ||           d S )
Nrg   r   r      )r   r0   r{   r   rL   r   rE   )rq   r         "@g      0@r`   r|   r   rN   rR   r7   r8   r9   )r:   sqr   r   s       r$   test_interp_quadz*TestSeriesInterpolateData.test_interp_quad  s}    G$$$Q262&lll;;;{33///|||DDD
vx00000r&   c                     t          j        d           t          ddt          j        dt          j        dg          }t          g d          }|                    d          }t          j        ||           d	}t          j        t          |
          5  |                    dd          }d d d            n# 1 swxY w Y   t          j        ||           t          g d          }|                    d          }t          j        ||
                    d                     t          j        t          |
          5  |                    dd          }d d d            n# 1 swxY w Y   t          j        ||           t          g d          }|                    d          }t          j        ||
                    d                     t          j        t          |
          5  |                    dd          }d d d            n# 1 swxY w Y   t          j        ||           t          g d          }|                    d          }t          j        ||           t          j        t          |
          5  |                    dd          }d d d            n# 1 swxY w Y   t          j        ||           t          g d          }|                    d          }t          j        ||           d S )Nrg   r   r{   rj      )rq   ry   g      @rn   g     2@      9@r   rE   z:The 'downcast' keyword in Series.interpolate is deprecatedr]   infer)r"   downcast)r   r{   r{   rj   rj   r   r   rQ   r   )r   ry   g:/KK@rn   gL82@r   r   )rq   ry   g333333@rn   g3333332@r   r   )r`   r|   r   rN   rR   r7   r8   r9   assert_produces_warningFutureWarningrS   r:   r   r   r   rd   s        r$   test_interp_scipy_basicz1TestSeriesInterpolateData.test_interp_scipy_basic  s   G$$$Aq"&"bfb122;;;<<i00
vx000J'SAAA 	G 	G]])g]FFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G
vx000///00i00
vxw'?'?@@@'SAAA 	G 	G]])g]FFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G
vx000///00f--
vxw'?'?@@@'SAAA 	D 	D]]&7]CCF	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D
vx000 CCCDDk22
vx000'SAAA 	I 	I]]+]HHF	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I
vx000;;;<<g..
vx00000sH   B;;B?B?E))E-0E-3HHHJ22J69J6c                    t          ddt          j        t          j        t          j        dg          }t          ddddt          j        dg          }|                    d	d
          }t	          j        ||           d S )Nr   r{   ri   rq   ry         @      @rm   r   r0   r"   limitr   r:   r   r   r   s       r$   test_interp_limitz+TestSeriesInterpolateData.test_interp_limitG  sl    Aq"&"&"&"5663S#rvt<==ha88
vx00000r&   r   r   c                     t          ddt          j        dg          }|\  }}t          j        t
          d          5   |j        d||d| d d d            d S # 1 swxY w Y   d S )Nr   r0   r   zLimit must be greater than 0r]   r   r"   rG   r_   )r:   r%   r   r   r"   r#   s         r$   *test_interpolate_invalid_nonpositive_limitzDTestSeriesInterpolateData.test_interpolate_invalid_nonpositive_limitN  s     Aq"&!$%%+]:-KLLL 	@ 	@AM?f?????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   AA #A c                     t          ddt          j        dg          }|\  }}d}t          j        t
          d          5   |j        d||d| d d d            d S # 1 swxY w Y   d S )	Nr   r0   r   ru   zLimit must be an integerr]   r   rG   r_   )r:   r%   r   r"   r#   r   s         r$   $test_interpolate_invalid_float_limitz>TestSeriesInterpolateData.test_interpolate_invalid_float_limitV  s    Aq"&!$%%+]:-GHHH 	@ 	@AM?f?????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s    AA"%A"invalid_methodNnonexistent_methodc                    t          ddt          j        dt          j        dg          }d| d}|d}t          j        t
          |          5  |                    |	           d d d            n# 1 swxY w Y   t          j        t
          |          5  |                    |d
           d d d            d S # 1 swxY w Y   d S )Nr   r{   rj   r   zmethod must be one of.* Got 'z	' insteadz%'method' should be a string, not Noner]   rE   r   r   r_   )r:   r   r   rd   s       r$   test_interp_invalid_methodz4TestSeriesInterpolateData.test_interp_invalid_method^  sJ   Aq"&"bfb122GnGGG!9C]:S111 	1 	1MMM000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1
 ]:S111 	; 	;MMrM:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   A22A69A6B==CCc                 \   t          ddt          j        dt          j        dg          }d}d}t          j        t
          |          5  t          j        t          |          5  |	                    dd	           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )
Nr   r{   rj   r   z:'fill_value' is not a valid keyword for Series.interpolate"Series.interpolate with method=padr]   pad)
fill_valuer"   )
r   rN   rR   r`   ra   rb   r8   r   r   r7   )r:   r<   rd   msg2s       r$   $test_interp_invalid_method_and_valuez>TestSeriesInterpolateData.test_interp_invalid_method_and_valuem  s$   aBFB344J3]:S111 	< 	<+MFFF < <1U;;;< < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s6   	B!%B	=B!	B	B!B	B!!B%(B%c                 ^   t          ddt          j        t          j        t          j        dg          }t          ddddt          j        dg          }|                    d	d
d          }t	          j        ||           |                    d	d
d          }t	          j        ||           d S )Nr   r{   ri   rq   ry   r   r   rm   r   r0   forwardr"   r   limit_directionFORWARDr   r   s       r$   test_interp_limit_forwardz3TestSeriesInterpolateData.test_interp_limit_forwardw  s    Aq"&"&"&"566 3S#rvt<==haSS
vx000haSS
vx00000r&   c           
      F   t          t          j        ddt          j        t          j        t          j        dt          j        g          }t          g d          }|                    dd          }t	          j        ||           t          t          j        dddd	d
ddg          }|                    dd          }t	          j        ||           t          ddddd	d
dt          j        g          }|                    dd          }t	          j        ||           d S )Nrq   ry   rm   )rq   rq   ry   r   r   r   rm   rm   r   bothr"   r   r   r   r   r   backwardr   r   s       r$   test_interp_unlimitedz/TestSeriesInterpolateData.test_interp_unlimited  s    BFCbfbfbfdBFKLLDDDEEhGG
vx000263S#sD$GHHh	JJ
vx0003S#sCrvFGGh
KK
vx00000r&   c                    t          ddt          j        t          j        t          j        dg          }d}t          j        t
          |          5  |                    ddd	           d d d            n# 1 swxY w Y   t          j        t
          |          5  |                    dd
           d d d            d S # 1 swxY w Y   d S )Nr   r{   ri   zVInvalid limit_direction: expecting one of \['forward', 'backward', 'both'\], got 'abc'r]   r   r0   abcr   r   r_   r   s      r$   test_interp_limit_bad_directionz9TestSeriesInterpolateData.test_interp_limit_bad_direction  sf   Aq"&"&"&"566/ 	 ]:S111 	K 	KMMEMJJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K ]:S111 	B 	BMM5MAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs$   A66A:=A:CCCc                    t          t          j        t          j        dt          j        t          j        t          j        dt          j        t          j        g	          }t          t          j        t          j        dddddt          j        t          j        g	          }|                    dd	
          }t	          j        ||           t          t          j        t          j        ddt          j        t          j        dt          j        t          j        g	          }|                    dd	d          }t	          j        ||           t          t          j        t          j        ddt          j        ddt          j        t          j        g	          }|                    dd	dd          }t	          j        ||           t          t          j        t          j        dt          j        t          j        t          j        dddg	          }|                    dd
          }t	          j        ||           t          t          j        t          j        dt          j        t          j        t          j        ddt          j        g	          }|                    ddd          }t	          j        ||           t          t          j        ddt          j        t          j        t          j        ddt          j        g	          }|                    dddd          }t	          j        ||           t          dddt          j        t          j        t          j        dt          j        t          j        g	          }|                    ddd          }t	          j        ||           d}t          j        t          |          5  |                    dd
           d d d            d S # 1 swxY w Y   d S )Nr{      ry   r   r         @r   r   insider"   
limit_arear   r"   r   r   r   )r"   r   r   r   outsider   )r"   r   r   zEInvalid limit_area: expecting one of \['inside', 'outside'\], got abcr]   r   )	r   rN   rR   r7   r8   r9   r`   ra   rb   r   s        r$   test_interp_limit_areaz0TestSeriesInterpolateData.test_interp_limit_area  sD   BFBFArvrvrvq"&"&QRR26263S#sBFBFSTTh8DD
vx000VRVS#rvrvsBFBFK
 
 h81MM
vx00026263RVS#rvrvVWW&PQ  
 
 	vx00026263SRUVWWh9EE
vx000VRVS"&"&"&#sBFK
 
 h9ANN
vx000263RVRVRVS#rvVWW	6QR  
 
 	vx0003S"&"&"&#rvrvVWW	:  
 
 	vx000 W]:S111 	= 	=MMeM<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   O,,O03O0z!method, limit_direction, expected))r   r   r   )ffillr   r   )backfillr   r   )bfillr   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   c                 :   t          g d          }d| d| d}d}t          j        t          |          5  t	          j        t          |          5  |                    ||           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r0   r{   z`limit_direction` must be 'z' for method ``zSeries.interpolate with method=r]   r   )r   r`   ra   rb   r8   r   r   r7   )r:   r"   r   r   r   rd   r   s          r$   "test_interp_limit_direction_raisesz<TestSeriesInterpolateData.test_interp_limit_direction_raises  sQ    999MHMMFMMM0]:S111 	N 	N+MFFF N NV_MMMN N N N N N N N N N N N N N N	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Ns5   BA8,B8A<	<B?A<	 BBBzdata, expected_data, kwargsr{   r   ry   r   r   r   r   r   r   r.   c                     t          |          }t          |          }d}t          j        t          |          5   |j        di |}d d d            n# 1 swxY w Y   t          j        ||           d S )Nr   r]   rG   r   r8   r   r   r7   r9   r:   dataexpected_datar#   r   r   rd   r   s           r$   test_interp_limit_area_with_padz9TestSeriesInterpolateData.test_interp_limit_area_with_pad  s    L 4LL-((2'SAAA 	- 	-"Q],,V,,F	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-
vx00000   AAAr   c                     t          |          }t          |          }d}t          j        t          |          5   |j        di |}d d d            n# 1 swxY w Y   t          j        ||           d S )Nz$Series.interpolate with method=bfillr]   rG   r   r   s           r$   $test_interp_limit_area_with_backfillz>TestSeriesInterpolateData.test_interp_limit_area_with_backfill  s    8 4LL-((4'SAAA 	- 	-"Q],,V,,F	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-
vx00000r  c                 f   t          ddt          j        t          j        t          j        dg          }t          ddt          j        dddg          }|                    d	d
d          }t	          j        ||           t          dddt          j        ddg          }|                    d	dd          }t	          j        ||           t          ddt          j        t          j        t          j        ddt          j        t          j        dt          j        g          }t          g d          }|                    d	d
d          }t	          j        ||           t          dddt          j        dddddddg          }|                    d	dd          }t	          j        ||           d S )Nr   r{   ri   rq   ry   r   r   rm   r   r0   r   r   r   r   r   r   rj   )rq   ry   r   r   r   r   r         $@rm   rn   rn   r   r   r  rn   r   r   s       r$   test_interp_limit_directionz5TestSeriesInterpolateData.test_interp_limit_direction7  s{   Aq"&"&"&"5663RVS#t<==haTT
vx0003S"&#t<==haPP
vx000 Aq"&"&"&!QBFSTTUUUVVhaPP
vx000#sBFCc4tTJ
 
 haPP
vx00000r&   c                    t          t          j        t          j        dddt          j        g          }t          dddddt          j        g          }|                    ddd	
          }t	          j        ||           t          g d          }|                    ddd
          }t	          j        ||           d S )Nr.   r   r   r   r   r   r   r0   r   r   )r   r   r   r   r   r   r   r   r   s       r$   test_interp_limit_to_endsz3TestSeriesInterpolateData.test_interp_limit_to_endsP  s    BFBFAq!RV4553S#sBF;<<haTT
vx00088899haPP
vx00000r&   c                    t          t          j        t          j        ddt          j        t          j        g          }t          t          j        t          j        dddt          j        g          }|                    ddd          }t	          j        ||           t          t          j        dddt          j        t          j        g          }|                    ddd	          }t	          j        ||           t          t          j        ddddt          j        g          }|                    ddd
          }t	          j        ||           d S )Nr.   r   r   r   r   r   r   r   r   r   r   r   s       r$   test_interp_limit_before_endsz7TestSeriesInterpolateData.test_interp_limit_before_ends\  s   BFBFAq"&"&9::26263S"&ABBhaSS
vx000263S"&"&ABBhaTT
vx000263S#rv>??haPP
vx00000r&   c                     t          j        d           t          g d          }|                    dd          }t	          j        ||           |                                }t	          j        ||           d S )Nrg   r   r   r   r   )r`   r|   r   r7   r8   r9   )r:   r   r   s      r$   test_interp_all_goodz.TestSeriesInterpolateData.test_interp_all_goodl  st    G$$$999l!<<
vq))) 
vq)))))r&   check_scipyFTc                    t          j        g d          }t          ddt          j        g|          }|                                }d|j        d<   |                                }t          j	        ||           d}|rMt          j        t          |          5  |                    dd           d d d            d S # 1 swxY w Y   d S d S )	N))r   a)r   b)r0   cr   r0   rL   z?Only `method=linear` interpolation is supported on MultiIndexesr]   r   r   )r   from_tuplesr   rN   rR   r2   r   r7   r8   r9   r`   ra   rb   )r:   r  idxr   r   r   rd   s          r$   test_interp_multiIndexz0TestSeriesInterpolateData.test_interp_multiIndexv  s    $%C%C%CDDAq"&>---6688Q
vx000O 	<z555 < <\;;;< < < < < < < < < < < < < < < < < <	< 	<s   C  CCc                    t          j        d           t          dt          j        dgg d          }d}t          j        t          |          5  |                    d	           d d d            d S # 1 swxY w Y   d S )
Nrg   r   r{   )r   r0   r   rL   z8krogh interpolation requires that the index be monotonicr]   r   rE   r`   r|   r   rN   rR   ra   rb   r7   r   s      r$   test_interp_nonmono_raisez3TestSeriesInterpolateData.test_interp_nonmono_raise  s    G$$$Arvq>333H]:S111 	* 	*MMM)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   A66A:=A:r"   r   c                    t          j        d           t          dt          j        dgt          dd|                    }|dk    rd nt          }d}t          j        ||	          5  |	                    |
          }d d d            n# 1 swxY w Y   |)|
                                }t          j        ||           t          g dt          dd|                    }t          j        ||           d S )Nrg   r   r{   1/1/2000r/   tzrL   r   0Series.interpolate with method=pad is deprecatedr]   rE   )rq   rq   ry   )r`   r|   r   rN   rR   r   r   r8   r   r7   r   r9   )	r:   r"   tz_naive_fixturedfwarnrd   r   altr   s	            r$   test_interp_datetime64z0TestSeriesInterpolateData.test_interp_datetime64  sK   G$$$N*ZGW"X"X"X
 
 
 **tt@'C888 	3 	3^^6^22F	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3((**C"63///OOZ7GHHH
 
 
 	vx00000s   *BBBc                    t          ddd          }t          |          }t          j        |d<   d}t	          j        t          |          5  |                    d	          }d d d            n# 1 swxY w Y   |                                }t	          j	        ||           t          |          }|d
         |d<   t	          j	        ||           d S )Nz
2015-04-05r{   z
US/Centralr  r   r  r]   r   rE   r   )
r   r   r3   r4   r8   r   r   r7   r   r9   )r:   dtir<   rd   r   r"  r   s          r$   #test_interp_pad_datetime64tz_valuesz=TestSeriesInterpolateData.test_interp_pad_datetime64tz_values  s   q\BBBSkkA@'SAAA 	3 	3__E_22F	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 iikk
vs+++#;;qk
vx00000s   A11A58A5c                     t          g d          }|                    d          }|}t          j        ||           d S )Nrq   ru   ry   r   )r   )r   r7   r8   r9   r   s       r$   test_interp_limit_no_nansz3TestSeriesInterpolateData.test_interp_limit_no_nans  sD    ???##Q''
vx00000r&   r   c                     t          j        d           t          ddt          j        dg          }d}t          j        t          |          5  |                    |           d d d            d S # 1 swxY w Y   d S )Nrg   r   r   r{   z6You must specify the order of the spline or polynomialr]   rE   r  )r:   r"   r   rd   s       r$   test_no_orderz'TestSeriesInterpolateData.test_no_order  s     	G$$$Aq"&!$%%F]:S111 	) 	)MMM(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A33A7:A7r   g      r   c                    t          j        d           t          ddt          j        dg          }d}t          j        t          |          5  |                    d|           d d d            d S # 1 swxY w Y   d S )	Nrg   r   r   r{   z.order needs to be specified and greater than 0r]   r   r   r  )r:   r   r   rd   s       r$   %test_interpolate_spline_invalid_orderz?TestSeriesInterpolateData.test_interpolate_spline_invalid_order  s    G$$$Aq"&!$%%>]:S111 	8 	8MMM777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   A44A8;A8c           	          t          j        d           t          ddt          j        ddt          j        dg          }|                    dd          }t          g d	          }t          j        ||           d S )
Nrg   r   r0   r   r.   r   r   r   rq   ru   ry   r   r   r   r   r   r   s       r$   test_splinez%TestSeriesInterpolateData.test_spline  su    G$$$Aq"&!Q233ha88===>>
vx00000r&   c           	      z   t          j        d           t          ddddt          j        dt          j        g          }|                    ddd          }t          g d	          }t          j        ||           |                    ddd
          }t          g d          }t          j        ||           d S )Nrg   r   r0   r{   r      r   )r"   r   ext)rq   ru   ry   r   r   r   r   r   r/  r   )r:   r   result3	expected3result1	expected1s         r$   test_spline_extrapolatez1TestSeriesInterpolateData.test_spline_extrapolate  s    G$$$Aq!Q26233--xqa-@@>>>??	
w	222--xqa-@@>>>??	
w	22222r&   c           	          t          j        d           t          ddt          j        ddt          j        dg          }|                    ddd	
          d         |                    dd          d         k    sJ d S )Nrg   r   r0   r   gffffff@r   r   r{   r   )r"   r   r   r.   r   )r`   r|   r   rN   rR   r7   )r:   r   s     r$   test_spline_smoothz,TestSeriesInterpolateData.test_spline_smooth  s    G$$$Aq"&!S"&!455MMaM88;}}HA}66q9: : : : : :r&   c                    t          j        d           t          t          j        d          dz  d          }t          j        |t          j                            d                              ddd          <   |	                    d	d
          }|	                    d	d
          }t          j        ||           d S )Nrg   rD   r0   rQ   rB   r   r   r{   r   r   r   )r`   r|   r   rN   rO   rR   r   r   integersr7   r8   r9   )r:   r   r6  r7  s       r$   test_spline_interpolationz3TestSeriesInterpolateData.test_spline_interpolation  s    G$$$29R==A%W5558:")


"
"
+
+Aq!
4
45--xq-99MMM;;	
w	22222r&   c                    t          dt          j        dgt          j        g d                    }|                    d          }t          g dt          j        g d                    }t          j        ||           t          dt          j        dgt          j        g d                    }|                    d          }t          g d	t          j        g d                    }t          j        ||           d S )
Nr   r{   r   rL   rM   rE   r(  )r   r0   r   )rq   g(%?ry   )r   rN   rR   r3   to_timedeltar7   r8   r9   )r:   r   r   r   s       r$   test_interp_timedelta64z1TestSeriesInterpolateData.test_interp_timedelta64  s    QN"/)))*D*DEEEv..///1K1KLLL
vx000 QN"/)))*D*DEEEv.....boiii6P6PQQQ
vx00000r&   c                 h   t          ddd          }t          t          j                            d                              t          |                    |          }t          j        |d d d<   |                    d          }|                                }t          j
        ||           d S )	Nr  z	1/20/2000r1   )freqr0   rL   r
   rE   )r   r   rN   r   r   r   rP   rR   r7   r8   r9   )r:   rngrU   r   exps        r$   %test_series_interpolate_method_valuesz?TestSeriesInterpolateData.test_series_interpolate_method_values  s    [s;;;BI))!,,<<SXXFFcRRR&33Q3x00nn
vs+++++r&   c                 l   t          ddd          }t          g d|          }|                    |t          j        d          z                                             }|                    |                              d	          }t          ddd
          }t          g d|          }|                    |t          j        d          z                                             }|                    |                              d	          }t          j	        |j
        |j
                   d S )Nz1/1/2012r   12D)r/   rB  )r   rj      $   r   )daysrM   rE   12h)hours)r   r   appendr3   
DateOffsetsort_valuesr~   r7   r8   assert_numpy_array_equalr
   )r:   r	   rU   r   rD  r   s         r$    test_series_interpolate_intradayz:TestSeriesInterpolateData.test_series_interpolate_intraday  s   :qu===OOOU++LLA)>)>)>!>??KKMM	jj##//v/>>:qu===OOOU++LLQ)?)?)?!?@@LLNN	I&&22&2AA
#FM3:>>>>>r&   ind)r  r  r  rJ   z
2019-01-01r   startr/   )rT  endc                    t          j        ddt          j        dg|          }|\  }}|dk    rt	          j        d           |dk    r> |d         j        di |}t          g dd|	          }t          j	        ||           d S d
| d}t	          j
        t          |          5   |d         j        dd|i| d d d            d S # 1 swxY w Y   d S )Nr   r   r{   rL   r   rg   r   r   namer	   z9Index column must be numeric or datetime type when using z_ method other than linear. Try setting a numeric or datetime index column before interpolating.r]   r"   rG   )r3   	DataFramerN   rR   r`   r|   r7   r   r8   r9   ra   rb   )	r:   r(   rR  r   r"   r#   r   r   expected_errors	            r$   test_interp_non_timedelta_indexz9TestSeriesInterpolateData.test_interp_non_timedelta_index  s\    \1a+3777+W(((X&RU&0000F222#FFFH"6844444!! ! !  z@@@ ; ;!1!:::6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   )CCCc                    t          j        d           t          j        dd          }t          j        ddt
          j        dg|          }|\  }}|dv r6|                    t           j        	                    | d	
                      |d         j
        dd|i|}t          g dd|          }t          j        ||           dS )z
        Tests for non numerical index types  - object, period, timedelta
        Note that all methods except time, index, nearest and values
        are tested here.
        rg   r   r   rS  r   r{   rL   >   r   r   z2 interpolation is not supported for TimedeltaIndexr+   r"   r   rW  NrG   )r`   r|   r3   timedelta_rangerY  rN   rR   applymarkermarkxfailr7   r   r8   r9   )	r:   r!   r(   rR  r   r"   r#   r   r   s	            r$    test_interpolate_timedelta_indexz:TestSeriesInterpolateData.test_interpolate_timedelta_index4  s     	G$$$ q!444\1a+3777+&&&!!$XXX "    
 #A";;&;F;;...QcBBB
vx00000r&   zascending, expected_values)r   r0   r{   r   rD   rD   r   r{   r0   r   c                     t          ddt          j        ddgg d          }|                    |                              d	          }t          ||t
          
          }t          j        ||           d S )NrD   r   r0   r   rb  )r   r	   )	ascendingr	   rE   )r   r	   rC   )r   rN   rR   
sort_indexr7   rQ   r8   r9   )r:   rd  expected_valuesrU   r   r   s         r$   test_interpolate_unsorted_indexz9TestSeriesInterpolateData.test_interpolate_unsorted_indexK  s{     "aA.6F6F6FGGG33??w?OOoUSSS
vx00000r&   c                 8   t          g dt                    }d}d}t          j        t          |          5  t          j        t          |          5  |                    d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N)r  Nr  rB   z$Series.interpolate with object dtypezInvalid fill methodr]   asfreqrE   )	r   r   r`   ra   rb   r8   r   r   r7   )r:   r<   r   rd   s       r$   test_interpolate_asfreq_raisesz8TestSeriesInterpolateData.test_interpolate_asfreq_raisesV  s   %%%V4445#]:S111 	1 	1+MFFF 1 1x0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s5   BA7+B7A;	;B>A;	?BBBc                 *   t          j        d           t          t          j        ddt          j        dt          j        g          }|                    dd          }t          t          j        dddddg          }t          j        ||           d S )Nrg   r   r   r{   r   )r"   r   r   )r:   r<   r   r   s       r$   test_interpolate_fill_valuez5TestSeriesInterpolateData.test_interpolate_fill_value^  s}    G$$$bfaBFArv677	a@@261aAq122
vx00000r&   )C__name__
__module____qualname__r`   r_  r`  r@   r[   re   r   r   r   r   r   parametrizer   td
skip_if_nor   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rN   rR   ranger  r  r  r
  r  r  r  r  r#  r&  r)  r+  r-  r0  r8  r:  r=  r@  rE  rQ  r3   period_rangeinterval_ranger[  ra  rg  rj  rl  rG   r&   r$   r*   r*   P   s^	       [IJJ	6 	6 KJ	64 4 4&. . .1 1 1
 
 
< < <4< < << < < [FL'!44MBM'<R<R  	
 ; ; ;< < <.) ) ) [FL'!44MBM'<R<R  	
 1 1 11 1 11 1 11 1 1(1 (1 (1T1 1 1 [Wr1g..@ @ /.@@ @ @ [-6J/KLL; ; ML;< < <
1 
1 
11 1 1B B B-= -= -=^ [+		
 		
 		
 N N N [% BFBFBFArvrvNc3S"&"&I 99 BFBFBFArvrvNc26263O 1EE BFBFBFArvrvNbfbfbfc3L 	:: BFBFBFArvrvNbfbfbfc3O 	AFF HH 	AFF aa 	AFF5	
" "F1 1G" "F1 [% BFBFBFArvrvNc3S"&"&I"(;; BFBFBFArvrvNbfbfc3O"(QGG BFBFBFArvrvNc3RVRVL")<< BFBFBFArvrvNc2626263O")aHH!	
 21 13 211 1 12
1 
1 
11 1 1 * * * [|v|Dg8N8NOOOP < < <* * * [X	5'9::1 1 ;:1(1 1 1"1 1 1 [Xh'?@@) ) A@) [Wr4C&@AA8 8 BA81 1 1	3 	3 	3
 
 
3 3 31 1 1	, 	, 	,? ? ? [   BO,:::BA1---	
 ; ; ;,1 1 1. [$
   	!E+;+;+;#<= 1 1	 11 1 11 1 1 1 1r&   r*   )numpyrN   r`   pandas.util._test_decoratorsutil_test_decoratorsrq  pandasr3   r   r   r   r   r   pandas._testing_testingr8   fixturer%   r(   r*   rG   r&   r$   <module>r~     sW        ) ) ) ) ) ) ) ) )                            *	 	+ *	     $	 	% $	T1 T1 T1 T1 T1 T1 T1 T1 T1 T1r&   