
    iJ                     h    d dl m Z  d dlZd dlmZ d dlZd dlmZmZm	Z	m
Z
mZ d dlmZ  G d d      Zy)    )datetimeN)Pandas4Warning)PeriodSeries
date_rangeperiod_rangeto_datetimec                   H    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)TestCombineFirstc           
         t        ddd      }t        t        d      t        d      d      }||fD ]  }t        dt        j
                  t        j
                  d	d
t        j
                  dg|      }t        g d|      }|j                  |      }t        g d|t        j                        }t        j                  ||        y )Nz
1950-01-31z
1950-07-31ME)startendfreqz1950-1z1950-7M            index)	   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   dtype)
r   r   r   r   npnancombine_firstfloat64tmassert_series_equal)selfdidxpidxidxabresultexpecteds           k/app/cer_product_mecsu/.venv/lib/python3.12/site-packages/pandas/tests/series/methods/test_combine_first.py"test_combine_first_period_datetimez3TestCombineFirst.test_combine_first_period_datetime   s    ,TJ&"2x8HsS$< 	5C2662661a;3GA,C8A__Q'F33bjjQH""684	5    c                 b    |j                  |d d       }|j                  |j                  k(  sJ y )Nr   )r   name)r!   datetime_seriesr'   s      r)   test_combine_first_namez(TestCombineFirst.test_combine_first_name    s1     ..r/BC{{o22222r+   c                 |   t        j                  dt         j                        }t        |t        j                  dt         j                              }|dz  }t         j
                  |d d d<   |j                  |      }t        j                  ||       |j                  |      }t        j                  |      j                         sJ t        j                  |d d d   |d d d          t        j                  |dd d   |dd d          t        j                  t        d      D cg c]  }t        |       c}      }t        t         j                  j!                  d      j#                  d      |      }t        t        d      D cg c]  }t        |       c}|d d d   t$              }	|	j                  |      }t        j                  |	|j&                  |d d d             t        j                  |dd d   j)                  t$              |j&                  |dd d             t        g dg d	      }
t        g g t$              }|
j                  |      }|s |
j*                  j)                  d
      |
_        t        j                  ||
j)                  t$                     y c c}w c c}w )N   r   r      r   
   r   )      ?r3      )r   r   r3   O)r   aranger   r   int64r   r   r   r    isfiniteallpdIndexrangestrrandomdefault_rngstandard_normalobjectlocastyper   )r!   using_infer_stringvaluesseriesseries_copycombinedir   floatsstringsseremptyr'   s                r)   test_combine_firstz#TestCombineFirst.test_combine_first$   s"   2RZZ0bii"((&CDqj66CaC ''4
x0 ,,V4{{8$((***
x!}fSqSk:
x1~{14a4/@A %)4Q#a&45		--a0@@DER%)4Q#a&4E#A#JfU((0
wU3Q3Z(@A
vadd|226:HLLqtRSt<UV [	2r62""5)!		((-CI
vszz&'9: 54s   .J4J9c                    t        t        dt        j                  g            j                  j                  |      }t        t        t        j                  dg            j                  j                  |      }|j                  |      }t        t        ddg            j                  j                  |      }t        j                  ||       y )N20102011)	r	   r   r   r   dtas_unitr   r   r    )r!   units0s1rsxps         r)   test_combine_first_dt64z(TestCombineFirst.test_combine_first_dt64I   s     01255==dC 01255==dCb! 01255==dC
r2&r+   c                    t        t        dt        j                  g            j                  j                  |      }t        t        j                  dg      }d}t        j                  t        |      5  |j                  |      }d d d        t        t        ddd      dgd| d	      }|d
v r|j                  j                  d      }t        j                  |       y # 1 sw Y   ]xY w)NrR   rS   z1Silently casting non-datetime 'other' to datetime)matchi  r   zdatetime64[]r2   )smsus)r	   r   r   r   rT   rU   r   assert_produces_warningr   r   r   r    )r!   rV   rW   rX   msgrY   rZ   s          r)   +test_combine_first_dt64_casting_deprecationz<TestCombineFirst.test_combine_first_dt64_casting_deprecationP   s     01255==dCRVVV$%A''cB 	&!!"%B	& XdAq)62KvQ:OP;t$B
r2&	& 	&s   6C$$C-c                 4   t        t        j                  g d|      d      }t        t        j                  g d|      g dd      }|j                  |      }t        j                  g d	|      }t        |d      }t	        j
                  ||       y )
N)201501012015010220150103tzser1)r-   )201605142016051520160516)r3   r6   r   ser2)r   r-   )rf   rg   rh   rm   rn   )r   r<   DatetimeIndexr   r   r    )r!   tz_naive_fixturerk   ro   r'   exp_valsexps          r)   test_combine_first_dt_tz_valuesz0TestCombineFirst.test_combine_first_dt_tz_values_   s    AFVW
 AFVW

 ##D)##H
 XF+
sF+r+   c           	         t        t        dddd      t        dddd      dd      }t        t        d      |      }t        |      }|j	                  |      }t        j                  ||j                  t        j                               y )Ni  r   r4   hzEurope/Rome)r   rj   r   )
r   r   r   r>   r   r   r    rE   r   r   )r!   
time_indexrX   s2r'   s        r)   4test_combine_first_timezone_series_with_empty_serieszETestCombineFirst.test_combine_first_timezone_series_with_empty_seriesq   sw    T1a#T1a$	

 E"IZ0*%!!"%
vryy'<=r+   c                     t        ddg      }t        g d      }|j                  |      }t        g d      }t        j                  ||       y )N   +YNJ9    M,YNJ9 )r   r3   r6   )r{   r|   r6   r   r   r   r    r!   rX   rx   r'   r(   s        r)   "test_combine_first_preserves_dtypez3TestCombineFirst.test_combine_first_preserves_dtype~   sH    (*=>?I!!"%GH
vx0r+   c           
         t        t        j                  dd      di      }t        t        j                  dd      dt        j                  dd      d	i      }|j                  |      }t        dd	gt        j                  t        j                  d
d      t        j                  dd      gd            }t        j                  ||       y )Nz
2019-05-01UTCri   r5   z2019-05-01 01:00:00+0100zEurope/Londong       @z
2019-05-02g      @z2019-05-01 00:00:00+00:00z2019-05-02 00:00:00+00:00rC   r2   r   )r   r<   	Timestampr   r=   r   r    )r!   
uniform_tzmulti_tzr'   r(   s        r)   test_combine_mixed_timezonez,TestCombineFirst.test_combine_mixed_timezone   s    R\\,5A3GH
7OLc\e4c
 ))(3#J((LL!<GLL!<G 	
 	vx0r+   c                     t        g dg d      }t        g dg d      }|j                  |      }t        d gdz  g d      }t        j                  ||       y )N)NNN)r%   r&   cr   )r&   r   dr   )r%   r&   r   r   r}   r~   s        r)   test_combine_first_none_not_nanz0TestCombineFirst.test_combine_first_none_not_nan   sO    &o>&o>!!"%4&1*,@A
vx0r+   N)__name__
__module____qualname__r*   r/   rP   r[   rd   rt   ry   r   r   r    r+   r)   r   r      s5    53#;J'',$>11.1r+   r   )r   numpyr   pandas.errorsr   pandasr<   r   r   r   r   r	   pandas._testing_testingr   r   r   r+   r)   <module>r      s,      (   R1 R1r+   