
    Owg                        d dl mZ d dlmZmZmZ d dlmZ d dlmZ d dl	Z	d dl
Z	d dl
mZ d dlZd dlZd dlZd dlmZmZmZ d dlZd dlmZmZmZmZmZmZ d dlmZ d d	lm Z   G d
 d      Z! G d d      Z"y)    )annotations)datetime	timedeltatimezone)partial)
attrgetterN)gettz)OutOfBoundsDatetimeastype_overflowsafe	timezones)DatetimeIndexIndex	Timestamp
date_rangeoffsetsto_datetime)period_arrayc            
         e Zd Zd Zd Zd Zd Zd Zej                  j                  d eddd	
       ej                  dd      g      d        Zd Zd Zd Zd Zd Zej                  j                  dddiddidddg      d        Zej                  j                  dddiddidddg      d        Zd Zd Zd Zd Zd Zej                  j                  dd g ed!d"d"      gg      d#        Zd$ Zd% Zd& Zej                  j                  d'd(d)g      d*        Z d+ Z!d, Z"ej                  j                  de#e$jJ                  e$jL                  g      d-        Z'd. Z(d/ Z)ej                  j                  dd0d1 e*jV                  d1       e,d2d13      jZ                  g      d4        Z.ej                  j                  dg d5      d6        Z/d7 Z0ej                  j                  d8e1e2g      ej                  j                  d9e$jf                   e4e$jf                  e#:      e5g      ej                  j                  d;d<d=g      d>                      Z6d? Z7d@ Z8dA Z9dB Z:dC Z;dD Z<dE Z=dF Z>dG Z?ej                  j                  d e*jV                  dH       e@dH      g      dI        ZAej                  j                  dJdHdKg      dL        ZBdM ZCej                  j                  dNdOdPg      dQ        ZDej                  j                  dJdHdKg      dR        ZEej                  j                  d e*jV                  dH       e@dH      g      ej                  j                  dSdTdUg      ej                  j                  dVe,e2g      dW                      ZFej                  j                  dg dX      dY        ZGdZ ZHd[ ZIej                  j                  dd\d]g      d^        ZJy0)_TestDatetimeIndexc                    d}t        j                  t        |      5  t        g d       d d d        y # 1 sw Y   y xY w)NzThe 'closed' keywordmatchT)closedtmassert_produces_warningFutureWarningr   selfmsgs     g/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/indexes/datetimes/test_constructors.pytest_closed_deprecatedz(TestDatetimeIndex.test_closed_deprecated&   s6    $''SA 	+"T*	+ 	+ 	+   5>c                    d}t        j                  t        |      5  t        g d       d d d        y # 1 sw Y   y xY w)NzThe 'normalize' keywordr   T)	normalizer   r   s     r!   test_normalize_deprecatedz+TestDatetimeIndex.test_normalize_deprecated,   s6    '''SA 	."-	. 	. 	.r#   c                    t        j                  dd      }t        |gd      }t        |j                  d      gd      }t	        j
                  ||       y )N   D
US/PacifictzM8[s])np
datetime64r   astyper   assert_index_equal)r   valresultexpecteds       r!   test_from_dt64_unsupported_unitz1TestDatetimeIndex.test_from_dt64_unsupported_unit2   sH    mmAs#u6 #**W"5!6<H
fh/    c                   t        ddd      }d}t        j                  t        |      5  t	        |d        d d d        t        j                  t        |      5  t	        t        j                  |      d        d d d        d}t        j                  t        |      5  t	        g d	d 
       d d d        y # 1 sw Y   xY w# 1 sw Y   JxY w# 1 sw Y   y xY w)N
2016-01-01
   UTCperiodsr,   z:Passed data is timezone-aware, incompatible with 'tz=None'r   r+   z3Cannot pass both a timezone-aware dtype and tz=NoneM8[ns, UTC]dtyper,   )r   pytestraises
ValueErrorr   r.   arrayr   dtir    s      r!   test_explicit_tz_nonez'TestDatetimeIndex.test_explicit_tz_none:   s    re<J]]:S1 	(#$'	( ]]:S1 	2"((3-D1	2 D]]:S1 	<"Md;	< 	<	( 	(	2 	2	< 	<s#   B;!C#C;CCCc                t   d}t        j                  t        |      5  t        t        j
                  t        d      gd       d d d        t        j                  t        |      5  t        t        j
                  t        d      j                  gd       d d d        y # 1 sw Y   ^xY w# 1 sw Y   y xY w)NQInferred frequency None from passed values does not conform to passed frequency Dr   
2011-01-01r)   freq)r@   rA   rB   r   pdNaTr   _valuer   s     r!   test_freq_validation_with_natz/TestDatetimeIndex.test_freq_validation_with_natI   s    $ 	 ]]:S1 	G2669\#:;#F	G]]:S1 	N2669\#:#A#ABM	N 	N	G 	G	N 	Ns   'B"(1B."B+.B7indexr8      r*   r;   z1 Dayr<   c                    |j                   }|g d   }|j                  J |j                  |      }|j                  J y )N)r            r(   )_datarK   _shallow_copy)r   rP   rC   arrr3   s        r!   %test_shallow_copy_inherits_array_freqz7TestDatetimeIndex.test_shallow_copy_inherits_array_freqV   sG     O$xx$$S){{"""r6   c                <   t        t        j                  dddgd      }||j                  fD ]l  }t        j                  |      }t        j
                  |      }t        j                  |      }|||fD ]#  }t        |      }t        j                  ||       % n y )Nz
2015-01-01z1999-04-06 15:14:13
US/Easternr+   )	r   rL   rM   rW   CategoricalIndexCategoricalSeriesr   r1   )r   rE   dtobjcicarrcserobjr3   s           r!   test_categorical_preserves_tzz/TestDatetimeIndex.test_categorical_preserves_tzh   s    VV\#8,GL
 399% 		3E $$U+B>>%(D99R=DD$' 3&s+%%fc23		3r6   c                2   t        j                  ddgd      }t        j                  t        d      5  t        |       d d d        t        j                  t        d      5  t        |       d d d        t        j                  t        d      5  t        t        |             d d d        t        j                  t        d      5  t        t        |             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w# 1 sw Y   y xY w)N2016Q12016Q2QrJ   zPeriodDtype data is invalidr   )rL   PeriodIndexr@   rA   	TypeErrorr   r   r   )r   datas     r!    test_dti_with_period_data_raisesz2TestDatetimeIndex.test_dti_with_period_data_raisesy   s    ~~x2=]]9,IJ 	 $	  ]]9,IJ 		 ]]9,IJ 	.,t,-	. ]]9,IJ 	,T*+	, 	,	  	 	 		. 	.	, 	,s/   C)$C5DD)C25C>D
Dc                \   t        j                  dgd      }d}t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        |       d d d        t        j                  t        |      5  t        t        j                  |             d d d        t        j                  t        |      5  t        t        j                  |             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   dxY w# 1 sw Y   y xY w)Nr   zm8[ns]r?   z3timedelta64\[ns\] cannot be converted to datetime64r   )	r.   rC   r@   rA   rk   r   r   rL   TimedeltaIndexr   rl   r    s      r!   %test_dti_with_timedelta64_data_raisesz7TestDatetimeIndex.test_dti_with_timedelta64_data_raises   s    xx8,D]]9C0 	 $	  ]]9C0 		 ]]9C0 	3"++D12	3 ]]9C0 	1))$/0	1 	1	  	 	 		3 	3	1 	1s/   C>%D
DD">D
DD"D+c                    t        d      t        d      g}t        j                  j                  |      }t	        |      }t        |      t        u sJ |j                  |j                  k(  sJ y )Nz2012-05-01T01:00:00.000000z2016-05-01T01:00:00.000000)r   rL   arraysSparseArrayr   typer?   )r   valuesrY   r3   s       r!   "test_constructor_from_sparse_arrayz4TestDatetimeIndex.test_constructor_from_sparse_array   sd     2323
 ii##F+sF|u$$$||syy(((r6   c           
     "   t        j                  t        dd      t        ddd      t        d      t         j                  t        d      gt        ddd      d	      }|j
                  j                  j                  j                  dk(  sJ y )
N20130101rT   rR   r\   r;   20130103ns)r<   rK   )dtdttzdt_with_nulldtns)	rL   	DataFramer   r   rM   r~   r?   r,   zone)r   dfs     r!   test_construction_cachingz+TestDatetimeIndex.test_construction_caching   sy    \\ Q7":q\Jj)FFj)!
 #:qtD	
 ww}}$$444r6   kwargsr,   zdtype.tzr?   r>   c           	         |}t        ddd|      }|j                         D ci c]  \  }}| t        |      |       }}}t        |fi |}t	        j
                  ||       y c c}}w )Nrz   rQ   hr<   rK   r,   )r   itemsr   r   r   r1   )r   r   tz_aware_fixturer,   ikeyr2   r3   s           r!   test_construction_with_altz,TestDatetimeIndex.test_construction_with_alt   sk    
 z132>:@,,.Ihc3#z#q))IIq+F+
a( Js   A'c           	        |}t        ddd|      }|j                  d       }|j                         D ci c]  \  }}| t        |      |       }}}d|v rKt	        |j
                  d      j                  |d         }t	        |fi |}t        j                  ||       t	        |j                  d       j
                  d      }	|j                  d       j                  d      }t        j                  |	|       d}
t        j                  t        |
	      5  t	        |j                  d       j
                  |j                  d
       d d d        y c c}}w # 1 sw Y   y xY w)Nrz   rQ   r   r   r,   r:   r+   -cannot supply both a tz and a dtype with a tzr   r*   r>   )r   
_with_freqr   r   r   asi8
tz_convertr   r1   tz_localizer@   rA   rB   r?   )r   r   r   r,   r   r   r2   r3   r4   i2r    s              r!   &test_construction_with_alt_tz_localizez8TestDatetimeIndex.test_construction_with_alt_tz_localize   s8   
 z132>LL:@,,.Ihc3#z#q))II6>"166e4??tMF$Q1&1H!!&(3 1==.33>==&2259
b(+ >]]:S1 	T!---22!''lS	T 	T J	T 	Ts   E2EE'c                   t        t        d      t        d      gd      }t        t        d      t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        dd	      t        d
d	      gd      }t        t        d      t        d
      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        dd	      t        dd	      gd      }t        t        d      t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        d      t        d
d	      gd      }t        t        d      t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        dd	      t        d
d	      gd      }t        t        dd	      t        d
d	      gdd      }t        j                  ||d       t        |t              rJ d}d}t        j                  t        |      5  t        j                  t        |      5  t        ddg       d d d        d d d        t        t        d      gd      }t        t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        dd	      gd      }t        t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ y # 1 sw Y   xY w# 1 sw Y   xY w)NrI   
2011-01-02idxnameTexact2011-01-01 10:00
Asia/Tokyor+   2011-01-02 10:00r,   r   r\   2011-08-01 10:00objectr?   r   z!DatetimeIndex has mixed timezonesz;parsing datetimes with mixed time zones will raise an errorr   z2013-11-02 22:00-05:00z2013-11-03 22:00-06:00)r   r   r   r   r1   
isinstancer,   r@   rA   rk   r   r   )r   r3   expr    msg_deprs        r!   ,test_construction_index_with_mixed_timezonesz>TestDatetimeIndex.test_construction_index_with_mixed_timezones   s   	,/<1HIPUV|$i&=>U
 	fc6&-000yy    ,>,> 
 )*I6H,IJ

 	fc6&-000yy$$$yyCFF""" ,>,> 
 )*I6H,IJ

 	fc6&-000yy$$$yyCFF""" ,-,> 
 ,-,> 
 	fc6fm444,>,> 
 ,>,> 
 	fc6fm4441P]]9C0 	T++MJ T79QRST	T
 	,/0u=Y|45EB
fc6&-000yy    	"4FGeT)*+5
 	fc6&-000yy$$$yyCFF"""%T T	T 	Ts$   4O%OO%O"	O%%O/c           	     d   t        t        j                  t        d      t        j                  t        d      gd      }t	        t        j                  t        d      t        j                  t        d      gd      }t        j                  ||d       t        |t              sJ |j                  J t        t        j                  t        dd	      t        j                  t        d
d	      gd      }t	        t        j                  t        d      t        j                  t        d
      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        dd	      t        j                  t        dd	      gd      }t	        t        d      t        j                  t        d      gdd      }t        j                  ||d       t        |t              sJ |j                  J |j                  |j                  k(  sJ t        t        j                  t        d      t        j                  t        d
d	      gd      }t        t        j                  t        d      t        j                  t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        j                  t        dd	      t        j                  t        d
d	      gd      }t        t        j                  t        dd	      t        j                  t        d
d	      gdd      }t        j                  ||d       t        |t              rJ t        t        j                  t        j                  gd      }t	        t        j                  t        j                  gd      }t        j                  ||d       t        |t              sJ |j                  J y )NrI   r   r   r   Tr   r   r   r+   r   r   r\   r   r   r   )	r   rL   rM   r   r   r   r1   r   r,   )r   r3   r   s      r!   5test_construction_index_with_mixed_timezones_with_NaTzGTestDatetimeIndex.test_construction_index_with_mixed_timezones_with_NaTB  s   VVY|,bffi6MN
 VVY|,bffi6MN
 	fc6&-000yy    ,>,>	 
 ,-,-	 	
 	fc6&-000yy$$$yyCFF""" ,>,>
 
 )*BFFI>P4QR

 	fc6&-000yy$$$yyCFF""" ,-,>	 
 ,-,>	 	
 	fc6fm444,>,>	 
 ,>,>	 	
 	fc6fm444 'e4RVVRVV,59
fc6&-000yy   r6   c                   t        t        d      t        d      gd      }t        t        d      t        d      gd      }t        j                  ||d       t	        |t               sJ t        t        dd	      t        d
d	      gd      }t        t        d      t        d
      gdd      }t        j                  ||d       t	        |t               sJ t        t        dd	      t        dd	      gd      }t        t        d      t        d      gdd      }t        j                  ||d       t	        |t               sJ d}t        j                  t        |      5  t        t        dd	      t        d
d	      gd       d d d        t        t        d      t        d
d	      gdd      }t        t        dd	      t        d
d	      j                  d      gdd      }t        j                  ||       t        t        dd	      t        d
d	      gdd      }t        t        dd	      j                  d      t        d
d	      gdd      }t        j                  ||       t        t        dd	      t        d
d	      gdd      }t        j                  ||       y # 1 sw Y   'xY w)NrI   r   r   r   Tr   r   r   r+   r   r   r\   r   z!cannot be converted to datetime64r   zM8[ns, US/Eastern]r   )	r   r   r   r1   r   r@   rA   rB   r   )r   r3   r   r    rE   r4   s         r!   *test_construction_dti_with_mixed_timezonesz<TestDatetimeIndex.test_construction_dti_with_mixed_timezones  s    |$i&=>U
 |$i&=>U
 	fc6&-000 ,>,> 
 )*I6H,IJ

 	fc6&-000 ,>,> 
 )*I6H,IJ

 	fc6&-000 2]]:S1 	0\B0\B 	 ,-,> 
 !,>,>II,W 
 	c8, ,>,> 
 !,>II,W,> 
 	c8, ,>,> '
 	c8,w	 	s   ,&J77Kc                z   t        d      t        j                  t        d      g}t        j                  t        |      t        |             t        j                  t        t        j                  |            t        t        j                  |                   t        j                  t        j                  t        d      g}t        j                  t        |      t        |             t        j                  t        t        j                  |            t        t        j                  |                   y )NrI   z
2011-01-03)
r   rL   rM   r   r1   r   r   r.   rC   nan)r   rY   s     r!   "test_construction_base_constructorz4TestDatetimeIndex.test_construction_base_constructor  s    &	,0GH
eCj-*<=
eBHHSM2M"((3-4PQvvrvvy67
eCj-*<=
eBHHSM2M"((3-4PQr6   c                B   t        ddd      t        ddd      t        ddd      t        ddd      g}t        |t              }t        j                  t        |      |       d}t        j                  t        |      5  t        |       d d d        y # 1 sw Y   y xY w)	Ni  r(   i  i  ip  ro   zH^Out of bounds nanosecond timestamp: 3000-01-01 00:00:00, at position 0$r   )	r   r   r   r   r1   r@   rA   r
   r   )r   datesr   r    s       r!   test_construction_outofboundsz/TestDatetimeIndex.test_construction_outofbounds&  s     T1a T1a T1a T1a 	
 E(
eElC0X]].c: 	!% 	! 	! 	!s    BBrl   z
1400-01-01ix  r(   c                ~    d}t        j                  t        |      5  t        |       d d d        y # 1 sw Y   y xY w)NzK^Out of bounds nanosecond timestamp: 1400-01-01( 00:00:00)?, at position 0$r   )r@   rA   r
   r   rq   s      r!   test_dti_date_out_of_rangez,TestDatetimeIndex.test_dti_date_out_of_range7  s:    5 	 ]].c: 	 $	  	  	 s   3<c                *   t        ddd      t        ddd      t        ddd      g}t        |t        j                               j                  }t        |t        j                               }t        g dd      }t        j                  ||       y )	Ni  r9         	   rJ   )z
2013-10-07z
2013-10-08z
2013-10-09B)r   r   r   BDayrw   r   r1   )r   r   rl   r3   r4   s        r!   test_construction_with_ndarrayz0TestDatetimeIndex.test_construction_with_ndarrayA  sr    $A&r1(=xbRS?TUU8??t',,.9 !KRUV
fh/r6   c                   t        j                  dd      }t        j                  |j                  d      g      }t	        |      j                  d      }t	        dgd      }t        j                  ||       t        j                  d       5  t	        |d	      }d d d        t	        dgd
      }t        j                  ||       y # 1 sw Y   .xY w)Nz2000-01-01 00:00:00r|   i8
US/Centralz2000-01-01T00:00:00zM8[ns, US/Central]ro   r:   r+   r=   )	r.   r/   rC   viewr   r   r   r1   r   )r   r2   rw   r3   r4   s        r!   -test_integer_values_and_tz_interpreted_as_utcz?TestDatetimeIndex.test_integer_values_and_tz_interpreted_as_utcI  s    mm148388D>*+v&22<@ "7!8@TU
fh/ ''- 	5"6e4F	5 "7!8N
fh/	5 	5s   C

Cc           
        d}t        j                  t        |      5  t        d       d d d        d t	        d      D        }t        |      }t        t	        d      D cg c]  }t        ddd      t        |      z    c}      }t        j                  ||       t        j                  g d      }t        |      }t        |j                  d	            }t        j                  ||       t        |j                        }t        j                  ||       t        j                  g d
      }t        |      }t        |j                  d	            }t        j                  ||       t        |j                        }t        j                  ||       d}t        j                  t        |      5  t        g dd       d d d        y # 1 sw Y   xY wc c}w # 1 sw Y   y xY w)Nz8DatetimeIndex\(\.\.\.\) must be called with a collectionr   1/1/2000c              3  N   K   | ]  }t        d dd      t        |      z     yw)  r(   N)r   r   ).0r   s     r!   	<genexpr>z>TestDatetimeIndex.test_constructor_coverage.<locals>.<genexpr>_  s"     Fqxa#il2Fs   #%r9   r   r(   )
2000-01-01
2000-01-02z
2000-01-03O)r   r   rM   rH   )r   r   z
2000-01-04r)   rJ   )r@   rA   rk   r   ranger   r   r   r1   r.   rC   r0   r   rB   )r   r    genr3   r   r4   strings	from_intss           r!   test_constructor_coveragez+TestDatetimeIndex.test_constructor_coverageY  s   I]]9C0 	&*%	& GE"IFs# :?)DQXdAq!IaL0D
 	fh/ ((EFw' !45
fh/!(--0	
i2 ((>?w' !45
fh/!(--0	
i2$ 	 ]]:S1 	PD3O	P 	PE	& 	& E6	P 	Ps   G! G5G G G)rK   YSzW-SUNc           
        t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d	      }t        j
                  |j                  |j                         t        d
d|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d      }t        j
                  |j                  |j                         t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d	      }t        j
                  |j                  |j                         t        dd|      }t        dd|t        t        d                  }t        j                  ||       t        dd|d      }t        j
                  |j                  |j                         y )Nz2013-01-01T00:00:00-05:00z2016-01-01T23:59:59-05:00rJ   z2013-01-01T00:00:00z2016-01-01T23:59:59i)minutesrK   r,   zAmerica/Limaz2013-01-01T00:00:00+09:00z2016-01-01T23:59:59+09:00i  r   z2013/1/1 0:00:00-5:00z2016/1/1 23:59:59-5:00z2013/1/1 0:00:00+9:00z2016/1/1 23:59:59+09:00)r   r   r   r   r1   assert_numpy_array_equalr   )r   rK   r   r4   expected_i8s        r!   $test_constructor_datetime64_tzformatz6TestDatetimeIndex.test_constructor_datetime64_tzformat  s    ')D4
 !!	$/0	
 	c8, !#8t
 	##CHHk.>.>?')D4
 !!	#./	
 	c8, !#8t
 	##CHHk.>.>? 02JQUV!!	$/0	
 	c8, !#8t
 	##CHHk.>.>?02KRVW!!	#./	
 	c8, !#8t
 	##CHHk.>.>?r6   c                   t        ddgd      }t        ddg      j                  d      j                  d      }t        j                  ||       t        ddgd      j                  d      }t        j                  ||       y )N
2013-01-01
2013-01-02datetime64[ns, US/Eastern]ro   r|   r\   r+   )r   as_unitr   r   r1   )r   r   r4   s      r!   test_constructor_dtypez(TestDatetimeIndex.test_constructor_dtype  s}    <(0L
 <67WT][& 	
 	c8,\<8\JRRSWX
c8,r6   c                   t        ddgd      }d}t        j                  t        |      5  t        |d       d d d        d}t        j                  t        |      5  t        |d	       d d d        d
}t        j                  t        |      5  t        |dd       d d d        t        |d      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   mxY w# 1 sw Y   ExY w)Nr   r   r   ro   zNcannot supply both a tz and a timezone-naive dtype \(i\.e\. datetime64\[ns\]\)r   datetime64[ns]zDdata is already tz-aware US/Eastern, unable to set specified tz: CETzdatetime64[ns, CET]r   CET)r,   r?   )r   r@   rA   rB   rk   r   r1   )r   r   r    r3   s       r!   )test_constructor_dtype_tz_mismatch_raisesz;TestDatetimeIndex.test_constructor_dtype_tz_mismatch_raises  s    <(0L

+ 	 ]]:S1 	7#%56	7 U]]9C0 	<#%:;	<=]]:S1 	M#%/KL	M s*FG
c6*	7 	7
	< 	<	M 	Ms#   C CC&CC#&C/c                    d}t        j                  t        |      5  t        ddg|       d d d        y # 1 sw Y   y xY w)NzUnexpected value for 'dtype'r   r(   rU   ro   )r@   rA   rB   r   )r   r?   r    s      r!   %test_constructor_invalid_dtype_raisesz7TestDatetimeIndex.test_constructor_invalid_dtype_raises  s:     -]]:S1 	/1a&.	/ 	/ 	/s	   7A c                n    t        d      }t        |g      }|j                  d   |j                  k(  sJ y )Nl   )b0Z4 r   )r   r   
nanosecond)r   t1r   s      r!   test_000constructor_resolutionz0TestDatetimeIndex.test_000constructor_resolution  s4    EFRD!~~a BMM111r6   c                    t        dgd      }d}t        j                  t        |      5  t	        j
                  d      |_        d d d        y # 1 sw Y   y xY w)N2010r:   r+   zCannot directly set timezoner   r*   )r   r@   rA   AttributeErrorpytzr   r,   rD   s      r!   test_disallow_setting_tzz*TestDatetimeIndex.test_disallow_setting_tz  sH    VH/,]]>5 	1]]<0CF	1 	1 	1s   AANAmerica/Los_Angeles2000r+   c                    t        dd      }t        dd      }t        d|||      }t        ddgdd      }t        j                  ||       t        j                  d      |j                  u sJ y )	Nz2013-01-01 06:00:00r   r+   z2013-01-02 06:00:00r)   )rK   startendr,   zM8[ns, America/Los_Angeles])r?   rK   )r   r   r   r   r1   r   r   r,   )r   r,   r   r   r3   r4   s         r!   "test_constructor_start_end_with_tzz4TestDatetimeIndex.test_constructor_start_end_with_tz  sw     /4IJ-2GHEsrB "$9:/

 	fh/}}23vyy@@@r6   )r*   r\   r   c                    t        d|      j                  }t        dg|      }t        j                  |      |j                  u sJ y )Nr   r+   )r   r,   r   r   r   )r   r,   non_norm_tzr3   s       r!   )test_constructor_with_non_normalized_pytzz;TestDatetimeIndex.test_constructor_with_non_normalized_pytz  s?      2.11xK8}}R FII---r6   c                    t        dd      t        dd      g}t        |      }t        |d   j                         |d   j                         g      }t        j                  ||       y )Nz2016-10-30 03:00:00+0300zEurope/Helsinkir+   z2016-10-30 03:00:00+0200r   r(   )r   r   to_pydatetimer   r1   )r   tsr3   r4   s       r!   #test_constructor_timestamp_near_dstz5TestDatetimeIndex.test_constructor_timestamp_near_dst  sh     05FG05FG
 r" "Q%"5"5"7A9L9L9N!OP
fh/r6   klassboxro   z	tz, dtype)r*   zdatetime64[ns, US/Pacific])Nr   c                    t        d|      j                  d      } | ||j                  g      |      } ||g      }||k(  sJ y )Nz
2018-01-01r+   r|   ro   )r   r   rN   )r   r   r   r,   r?   r   r3   r4   s           r!   test_constructor_with_int_tzz.TestDatetimeIndex.test_constructor_with_int_tz"  sK     |+33D9sBII;'u5";!!!r6   c                P    |}d}t        |g|      j                  d   }||k(  sJ y )Nl     _S r+   r   )r   r   )r   tz_naive_fixturer,   r3   r4   s        r!   test_construction_int_rountripz0TestDatetimeIndex.test_construction_int_rountrip/  s3    $ &b166q9!!!r6   c           	         t        t        ddd      t        ddd      dd      }t        |D cg c]  }|j                  dd	
       c}      }t        g dd      }t	        j
                  ||       y c c}w )Nr           zYE-DECzAustralia/Melbourner      r(   )monthday)z2000-06-01 00:00:00z2001-06-01 00:00:00z2002-06-01 00:00:00z2003-06-01 00:00:00z2004-06-01 00:00:00z2005-06-01 00:00:00r+   )r   r   r   replacer   r1   )r   rP   xr3   r4   s        r!   3test_construction_from_replaced_timestamps_with_dstzETestDatetimeIndex.test_construction_from_replaced_timestamps_with_dst7  sz    dB#dB#$	
 5Ia		q	 9IJ  %

 	fh/  Js   A6c                    t        ddd      }d}t        j                  t        |      5  t	        |d       d d d        y # 1 sw Y   y xY w)	Nr8   rT   r   r;   z?data is already tz-aware US/Central, unable to set specified tzr   r   r+   )r   r@   rA   rk   r   rD   s      r!   *test_construction_with_tz_and_tz_aware_dtiz<TestDatetimeIndex.test_construction_with_tz_and_tz_aware_dtiM  sB    q\BO]]9C0 	0#,/	0 	0 	0s   AAc                    t         j                  j                         }t        ddg|      }t        t	        d|      t
        j                  g      }t        j                  ||       y )N2018rM   r+   )	dateutilr,   tzlocalr   r   rL   rM   r   r1   )r   r,   r3   r4   s       r!   &test_construction_with_nat_and_tzlocalz8TestDatetimeIndex.test_construction_with_nat_and_tzlocalT  sN    [[  "26 )Fr":BFF!CD
fh/r6   c                >   t        ddgddd      }d}t        dd	d
d
      j                  |d      }t        |dd      }t	        j
                  ||       d}t        dd	dd
      j                  |d      }t        |dd      }t	        j
                  ||       y )Nz2020-11-01 01:00:00z2020-11-02 01:00:00z datetime64[ns, America/New_York]r)   F)r?   rK   	ambiguouszAmerica/New_Yorki     r(   )yearr  r  hour)r  rU   )r   r<   r  )r   r<   r  )r   r   r   r   r   r1   )r   r4   r   r   r3   r   s         r!   +test_constructor_with_ambiguous_keyword_argz=TestDatetimeIndex.test_constructor_with_ambiguous_keyword_argZ  s     !"$9:4	
 &t211=II J 
 %eD
fh/ &T;GG H 
 Q%@
fh/r6   c                `   |}t        d      j                  |d      }t        |dd      }t        t        d|      t        d	|      g      }t	        j
                  ||       |}t        |dd
      }t        t        d|      t        d|      g      }t	        j
                  ||       y )Nz2015-03-29 02:30:00shift_forward)nonexistentrU   r   )r   r<   rK   z2015-03-29 03:00:00+02:00r+   z2015-03-29 04:00:00+02:00)r   r<   rK   z2015-03-29 01:00:00+01:00)r   r   r   r   r   r1   )r   warsawr   r   r3   r4   r   s          r!   -test_constructor_with_nonexistent_keyword_argz?TestDatetimeIndex.test_constructor_with_nonexistent_keyword_argt  s     /0<</ = 
 %= 5(C5(C
 	fh/ QS9 5(C5(C
 	fh/r6   c                   d}t        j                  t        |      5  t        dgd       d d d        d}t        j                  t        |      5  t	        dgd       d d d        y # 1 sw Y   >xY w# 1 sw Y   y xY w)Nz with no precision is not allowedr   r   r/   ro   z2The 'datetime64' dtype has no unit. Please pass in)r@   rA   rB   r   r   r   s     r!   $test_constructor_no_precision_raisesz6TestDatetimeIndex.test_constructor_no_precision_raises  st     1]]:S1 	86(,7	8 C]]:S1 	06(,/	0 	0		8 	8	0 	0s   A*A6*A36A?c                l    t        dgd      }|j                  dk(  sJ |d   t        ddd      k(  sJ y )Nr   zdatetime64[us]ro   M8[us]r   r   r(   )r   r?   r   )r   rE   s     r!   'test_constructor_wrong_precision_raisesz9TestDatetimeIndex.test_constructor_wrong_precision_raises  s>    VH,<=yyH$$$1v4A....r6   c                    t        t        j                  t        dd      t        j                  gt
                    }t        t        dd      t        j                  g      }t        j                  ||       y )N2019r:   r+   ro   )r   r.   rC   r   r   r   r   rL   rM   r   r1   )r   r3   r4   s      r!   Htest_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nanzZTestDatetimeIndex.test_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nan  sQ    rxx6e!<bff EVTU )Fu"=rvv!FG
fh/r6   r\   c                ~    t        ddd|      g}t        |      }t        j                  |j                  |      sJ y )N  r      )tzinfo)r   r   r   
tz_comparer,   )r   r,   drP   s       r!   test_dti_from_tzaware_datetimez0TestDatetimeIndex.test_dti_from_tzaware_datetime  s9    dAr"-.a ##EHHb111r6   tzstrzdateutil/US/Easternc                   ddg}t        |      j                  |      }t        ddd|      }|j                  d      }t	        ||      }t	        t        j                  |      |      }|||fD ]  }t        j                  ||        y)	z^Test different DatetimeIndex constructions with timezone
        Follow-up of GH#4229
        z11/10/2005 08:00:00z11/10/2005 09:00:00z2005-11-10 08:00:00r   rU   )r   rK   r<   r,   Nr+   )	r   r   r   r   r   r.   rC   r   r1   )r   r)  rY   idx1idx2idx3idx4others           r!   test_dti_tz_constructorsz*TestDatetimeIndex.test_dti_tz_constructors  s    
 %&;<3++E2 5CuUt$SU+RXXc]u5D$' 	/E!!$.	/r6   c                j    t        dddd|      }t        |d      }t        j                  ||       y )Nz03/12/2012 00:00r9   zW-FRIr\   )r<   rK   r,   unit)rl   r,   r   r   r   r1   )r   r2  rngrng2s       r!    test_dti_construction_idempotentz2TestDatetimeIndex.test_dti_construction_idempotent  s6    \PT
 #,7
c4(r6   prefix z	dateutil/c                ^    t        t        ddd      g|dz         }|j                   |d    y )Nr#  r(   ESTr+   r   )r   r   r  )r   r7  rP   s      r!   "test_dti_constructor_static_tzinfoz4TestDatetimeIndex.test_dti_constructor_static_tzinfo  s.     xa34%H

ar6   c                |    t        dd|d      }t        t        |      dd      }t        j                  ||       y )Nz
2012-06-02r9   foo)r<   r,   r   r)   )r   rK   )r   r   listr   r1   )r   r)  drdr2s       r!   test_dti_convert_datetime_listz0TestDatetimeIndex.test_dti_convert_datetime_list  s4    bUGDH5s;
b#&r6   use_strTFbox_clsc                   d}|}|st        |      j                         }|t         ur|g}|sUt        |t        j                  j
                        r1t        j                  j                  d      }|j                  |       t        j                  t        j                  |      5   |||       d d d        y # 1 sw Y   y xY w)Nz2013-11-03 01:59:59.999999zWe implicitly get fold=0.)reasonr   r+   )r   r   r   r  r,   tzfiler@   markxfailapplymarkerrA   r   AmbiguousTimeError)r   r,   rB  rC  requestdtstritemrG  s           r!   $test_dti_ambiguous_matches_timestampz6TestDatetimeIndex.test_dti_ambiguous_matches_timestamp  s     -U#113D)#6D:b(++*<*<=
 ;;$$,G$HD%]]422%@ 	!DR 	! 	! 	!s   'B;;C)Nr:   r*   c                b   t        d      }d}|d| d}|ddg}t        ||      }|d   j                  |      t        |d	   |
      t        |d   dd      j	                  |      g}|D cg c]  }|j                  d      j                   }}t        j                  |d      }	t        |	d      }
| |
j                  d      j	                  |      }
t        j                  ||
       t        t        j                  |t              |      }t        j                  ||
       y c c}w )Nz
2999-01-01r  zM8[us, ]z2999-01-02 03:04:05.678910i	  ro   r   r(   r+   rU   usT)r2  utcr:   )r   r   r   r   r   r   asm8r.   rC   r   r1   r   )r   r,   r   r?   valsr3   	pointwiser  exp_valsexp_arrr4   result2s               r!   (test_dti_constructor_with_non_nano_dtypez:TestDatetimeIndex.test_dti_constructor_with_non_nano_dtype  s    |$>bTOE0$7t51
 G#d1g"%Qd5@@D
	
 3<<QAIIdO((<<((884 9>++E2==bAH
fh/V <EJ
gx0 =s   /"D,c                   t        j                         }t        j                         }t        ddgd      }|j                  dk(  sJ t        j                  d      }|d   |j                  d      z
  }|t        j                  d      k\  sJ ||k  sJ |d   |j                  d      z
  }|t        j                  d      k\  sJ ||k  sJ y )	Nnowtodayr-   ro   r(   )microsecondsr   s)r   r[  r\  r   r?   rL   	Timedeltar   )r   r[  r\  r3   	tolerancediff0diff1s          r!   ,test_dti_constructor_with_non_nano_now_todayz>TestDatetimeIndex.test_dti_constructor_with_non_nano_now_today  s    mmo!w/w?||w&&& LLa0	q	CKK,,Q'''y   q	EMM#..Q'''y   r6   c                    t        j                  dt         j                  gt         j                        }|j	                  t
              }t        |d      }t        |d      }t        j                  ||       y )Nr   ro   r   r+   )	r.   rC   r   float64r0   r   r   r   r1   )r   rY   arr2dti1dti2s        r!   5test_dti_constructor_object_float_matches_float_dtypezGTestDatetimeIndex.test_dti_constructor_object_float_matches_float_dtype  sT    hh266{"**5zz&!SU+Te,
dD)r6   r  zM8[us, US/Pacific]c                   t        j                  dd      dz  }t        j                  j                  |d<   |j                  t         j                        }t         j                  |d<   |j                  t              }t        j                  |d<   |j                  t              }t        ||      }t        ||      }t        ||      }t        ||      }	t        |j                  d            }
|j                  *|
j                  d      j                  |j                        }
t        j                  ||
       t        j                  ||
       t        j                  ||
       t        j                  |	|
       y )NrQ   r   ro     r   r  r:   )r.   arangerL   rM   valuer0   re  r   r   r   r   r,   r   r   r   r1   )r   r?   vals1vals2vals3vals4res1res2res3res4r4   s              r!   <test_dti_constructor_with_dtype_object_int_matches_int_dtypezNTestDatetimeIndex.test_dti_constructor_with_dtype_object_int_matches_int_dtype(  s     		!4(4/66<<aRZZ(66aV$ 66aV$U%0U%0U%0U%0 H!5677++E2==dggFH
dH-
dH-
dH-
dH-r6   )K__name__
__module____qualname__r"   r&   r5   rF   rO   r@   rG  parametrizer   rL   timedelta_rangerZ   re   rm   rr   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   int32int64r   r   r   r   r   r   r,   r   r   r   r   r   rC   r   r>  r   r   r  r	  r  r  r  r  r  r!  r	   r(  r0  r6  r;  rA  rN  rY  rc  ri  rv   r6   r!   r   r   %   s   +.0<
N [[|Q<@Bw2	
	#	#3", 1 	)5 [[

	gw/7*1UV)	) [[

	gw/7*1UVT	T,h#Tl!\k-ZR!" [[V|nxa7K6L%MN  O 00 %PN [[VdG_5;@ 6;@z-+0 [[Wvrxx&BC/ D/21 [[!DMM/0f!67::		
AA [[T#MN. O.0 [[Wum&<=[[URXXwrxxv/NPT$UV[[	57OP"	 W >""0,00040<	0/
0 [[TMDMM,$?|AT#UV2 W2 [[W|5J&KL/ M/) [[XK'89 : [[W|5J&KL' M'
 [[DMM,',	
 [[Yu6[[YM(BC! D 7!* [[T#>?1 @14!&* [[Wx1E&FG. H.r6   r   c                      e Zd Zd Zd Zd Zd Zd Zd Ze	j                  j                  dg d      d	        Zd
 Zd Zy)TestTimeSeriesc                l    t        ddd      }t        |      }|j                  |j                  k(  sJ y Nr   z1/2/20005minrJ   )r   r   rK   )r   r4  r5  s      r!   &test_dti_constructor_preserve_dti_freqz5TestTimeSeries.test_dti_constructor_preserve_dti_freqH  s0    Zf=S!xx499$$$r6   c                    t        ddd      }t        |d       }|j                  J t        |j                  d       }|j                  J y r  )r   r   rK   rW   )r   r4  r3   s      r!   test_explicit_none_freqz&TestTimeSeries.test_explicit_none_freqN  sL    Zf=s.{{"""syyt4{{"""r6   c                    t        g d      }t        j                  g d|      }t        j                  t        |      |       y )N)z1970-01-01 00:00:00.00000000z1970-01-01 00:00:00.00000001z1970-01-01 00:00:00.00000002)r   r9      ro   )r   r.   rC   r   r1   )r   any_int_numpy_dtyper   rY   s       r!   test_dti_constructor_small_intz-TestTimeSeries.test_dti_constructor_small_intX  s9    
 hh{*=>
mC0#6r6   c                D    t        dg      }|d   j                  dk(  sJ y )Nz1-1-2000 00:00:01r   r(   )r   second)r   r4  s     r!   test_ctor_str_intradayz%TestTimeSeries.test_ctor_str_intradaye  s&    0121v}}!!!r6   c                    t        j                  dddt         j                        j                  d      }t	        |      }|j
                  t        |t        j                  d            k(  j                         sJ y )Nr   d   r9   ro   zM8[D]zM8[ns])	r.   rl  r}  r   r   rw   r   r?   all)r   rY   r   s      r!   &test_index_cast_datetime64_other_unitsz5TestTimeSeries.test_index_cast_datetime64_other_unitsi  sZ    ii3"((388ACj

1#RXXh=OPPUUWWWr6   c                d   t        j                  dt         j                        }t        |      }d|dd |j                  dd dk(  j                         sJ t        j                  dt         j                        }t        |d      }d|dd |j                  dd dk7  j                         sJ y )Nrk  ro   2   r  T)copy)r.   rl  r}  r   r   r  )r   rY   rP   s      r!   test_constructor_int64_nocopyz,TestTimeSeries.test_constructor_int64_nocopyo  s    iiBHH-c"Bs

2c"b(--///iiBHH-c-Bs

2c"b(--///r6   rK   )MEQEYEr)   r   bhminr^  msrQ  r   r|   Cc                    t        d|d      }t        ||      }t        j                  ||       t        d|dd      }t        ||d      }t        j                  ||       y )Nz2001/02/01 09:00r(   )r   rK   r<   rJ   r*   )r   rK   r,   r<   r   r3  )r   rK   orgr   s       r!   !test_from_freq_recreate_from_dataz0TestTimeSeries.test_from_freq_recreate_from_data}  sb    
 1aHCd+
c3'$4L!
 Cd|<
c3'r6   c                >   g d}d}t        j                  t        |      5  t        |       d d d        g d}t        |      }t	        ddd      ddd	g}t        |      }t        t	        ddd            ddd	g}t        |      }t        j                  g dd
      }t        |      }t        ddgd      }t        ddgdd      }t        j                  ||       |||fD ]+  }	|j                  |	j                  k(  j                         r+J  y # 1 sw Y   xY w)N)1/1/20051/2/2005z
Jn 3, 2005
2005-01-04z9(\(')?Unknown datetime string format(:', 'Jn 3, 2005'\))?r   )r  r  1/3/2005r  r  r(   r  r  r  r   ro   z
12/05/2007z
25/01/2008T)dayfirstz
2007/05/12z
2008/01/25F)r  	yearfirst)r@   rA   rB   r   r   r   r.   rC   r   r1   rw   r  )
r   rY   r    r+  r,  r-  r.  idx5idx6r/  s
             r!   #test_datetimeindex_constructor_miscz2TestTimeSeries.test_datetimeindex_constructor_misc  s   BJ]]:S1 	#	 AS!a#Z\JS!$1-.
JUS!hhIQTUS!lL9DI<(5D
 	dD)D$' 	7EKK5<</44666	7+	 	s   DDc                   d}t        dddd      }t        dddd      }t        |gdd	
      }t        |g      }t        j                  ||       t        |gdd	      }t        |g      }t        j                  ||       y )Nz5/10/16i  r9   rQ   r*   r+   r     T)r,   r  )r,   r  )r   r   r   r1   )r   r2   dfirstyfirstresult1	expected1rX  	expected2s           r!   <test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tzzKTestTimeSeries.test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tz  s    4Q<84RL9,F!6(+	
gy1,$G!6(+	
gy1r6   N)rw  rx  ry  r  r  r  r  r  r  r@   rG  rz  r  r  r  r~  r6   r!   r  r  G  sT    %#7"X0 [[R	(		(762r6   r  )#
__future__r   r   r   r   	functoolsr   operatorr   r  dateutil.tzr	   numpyr.   r@   r   pandas._libs.tslibsr
   r   r   pandasrL   r   r   r   r   r   r   pandas._testing_testingr   pandas.core.arraysr   r   r  r~  r6   r!   <module>r     sf    " 
             +_. _.D!m2 m2r6   