@@ -172,82 +172,88 @@ def test_normalize(self):
172172class TestDatetime64 (tm .TestCase ):
173173
174174 def test_datetimeindex_accessors (self ):
175- dti = DatetimeIndex (freq = 'D' , start = datetime (1998 , 1 , 1 ), periods = 365 )
176-
177- self .assertEqual (dti .year [0 ], 1998 )
178- self .assertEqual (dti .month [0 ], 1 )
179- self .assertEqual (dti .day [0 ], 1 )
180- self .assertEqual (dti .hour [0 ], 0 )
181- self .assertEqual (dti .minute [0 ], 0 )
182- self .assertEqual (dti .second [0 ], 0 )
183- self .assertEqual (dti .microsecond [0 ], 0 )
184- self .assertEqual (dti .dayofweek [0 ], 3 )
185-
186- self .assertEqual (dti .dayofyear [0 ], 1 )
187- self .assertEqual (dti .dayofyear [120 ], 121 )
188-
189- self .assertEqual (dti .weekofyear [0 ], 1 )
190- self .assertEqual (dti .weekofyear [120 ], 18 )
191-
192- self .assertEqual (dti .quarter [0 ], 1 )
193- self .assertEqual (dti .quarter [120 ], 2 )
194-
195- self .assertEqual (dti .days_in_month [0 ], 31 )
196- self .assertEqual (dti .days_in_month [90 ], 30 )
197-
198- self .assertEqual (dti .is_month_start [0 ], True )
199- self .assertEqual (dti .is_month_start [1 ], False )
200- self .assertEqual (dti .is_month_start [31 ], True )
201- self .assertEqual (dti .is_quarter_start [0 ], True )
202- self .assertEqual (dti .is_quarter_start [90 ], True )
203- self .assertEqual (dti .is_year_start [0 ], True )
204- self .assertEqual (dti .is_year_start [364 ], False )
205- self .assertEqual (dti .is_month_end [0 ], False )
206- self .assertEqual (dti .is_month_end [30 ], True )
207- self .assertEqual (dti .is_month_end [31 ], False )
208- self .assertEqual (dti .is_month_end [364 ], True )
209- self .assertEqual (dti .is_quarter_end [0 ], False )
210- self .assertEqual (dti .is_quarter_end [30 ], False )
211- self .assertEqual (dti .is_quarter_end [89 ], True )
212- self .assertEqual (dti .is_quarter_end [364 ], True )
213- self .assertEqual (dti .is_year_end [0 ], False )
214- self .assertEqual (dti .is_year_end [364 ], True )
215-
216- # GH 11128
217- self .assertEqual (dti .weekday_name [4 ], u'Monday' )
218- self .assertEqual (dti .weekday_name [5 ], u'Tuesday' )
219- self .assertEqual (dti .weekday_name [6 ], u'Wednesday' )
220- self .assertEqual (dti .weekday_name [7 ], u'Thursday' )
221- self .assertEqual (dti .weekday_name [8 ], u'Friday' )
222- self .assertEqual (dti .weekday_name [9 ], u'Saturday' )
223- self .assertEqual (dti .weekday_name [10 ], u'Sunday' )
224-
225- self .assertEqual (Timestamp ('2016-04-04' ).weekday_name , u'Monday' )
226- self .assertEqual (Timestamp ('2016-04-05' ).weekday_name , u'Tuesday' )
227- self .assertEqual (Timestamp ('2016-04-06' ).weekday_name , u'Wednesday' )
228- self .assertEqual (Timestamp ('2016-04-07' ).weekday_name , u'Thursday' )
229- self .assertEqual (Timestamp ('2016-04-08' ).weekday_name , u'Friday' )
230- self .assertEqual (Timestamp ('2016-04-09' ).weekday_name , u'Saturday' )
231- self .assertEqual (Timestamp ('2016-04-10' ).weekday_name , u'Sunday' )
232-
233- self .assertEqual (len (dti .year ), 365 )
234- self .assertEqual (len (dti .month ), 365 )
235- self .assertEqual (len (dti .day ), 365 )
236- self .assertEqual (len (dti .hour ), 365 )
237- self .assertEqual (len (dti .minute ), 365 )
238- self .assertEqual (len (dti .second ), 365 )
239- self .assertEqual (len (dti .microsecond ), 365 )
240- self .assertEqual (len (dti .dayofweek ), 365 )
241- self .assertEqual (len (dti .dayofyear ), 365 )
242- self .assertEqual (len (dti .weekofyear ), 365 )
243- self .assertEqual (len (dti .quarter ), 365 )
244- self .assertEqual (len (dti .is_month_start ), 365 )
245- self .assertEqual (len (dti .is_month_end ), 365 )
246- self .assertEqual (len (dti .is_quarter_start ), 365 )
247- self .assertEqual (len (dti .is_quarter_end ), 365 )
248- self .assertEqual (len (dti .is_year_start ), 365 )
249- self .assertEqual (len (dti .is_year_end ), 365 )
250- self .assertEqual (len (dti .weekday_name ), 365 )
175+ dti_naive = DatetimeIndex (freq = 'D' , start = datetime (1998 , 1 , 1 ),
176+ periods = 365 )
177+ # GH 13303
178+ dti_tz = DatetimeIndex (freq = 'D' , start = datetime (1998 , 1 , 1 ),
179+ periods = 365 , tz = 'US/Eastern' )
180+ for dti in [dti_naive , dti_tz ]:
181+
182+ self .assertEqual (dti .year [0 ], 1998 )
183+ self .assertEqual (dti .month [0 ], 1 )
184+ self .assertEqual (dti .day [0 ], 1 )
185+ self .assertEqual (dti .hour [0 ], 0 )
186+ self .assertEqual (dti .minute [0 ], 0 )
187+ self .assertEqual (dti .second [0 ], 0 )
188+ self .assertEqual (dti .microsecond [0 ], 0 )
189+ self .assertEqual (dti .dayofweek [0 ], 3 )
190+
191+ self .assertEqual (dti .dayofyear [0 ], 1 )
192+ self .assertEqual (dti .dayofyear [120 ], 121 )
193+
194+ self .assertEqual (dti .weekofyear [0 ], 1 )
195+ self .assertEqual (dti .weekofyear [120 ], 18 )
196+
197+ self .assertEqual (dti .quarter [0 ], 1 )
198+ self .assertEqual (dti .quarter [120 ], 2 )
199+
200+ self .assertEqual (dti .days_in_month [0 ], 31 )
201+ self .assertEqual (dti .days_in_month [90 ], 30 )
202+
203+ self .assertEqual (dti .is_month_start [0 ], True )
204+ self .assertEqual (dti .is_month_start [1 ], False )
205+ self .assertEqual (dti .is_month_start [31 ], True )
206+ self .assertEqual (dti .is_quarter_start [0 ], True )
207+ self .assertEqual (dti .is_quarter_start [90 ], True )
208+ self .assertEqual (dti .is_year_start [0 ], True )
209+ self .assertEqual (dti .is_year_start [364 ], False )
210+ self .assertEqual (dti .is_month_end [0 ], False )
211+ self .assertEqual (dti .is_month_end [30 ], True )
212+ self .assertEqual (dti .is_month_end [31 ], False )
213+ self .assertEqual (dti .is_month_end [364 ], True )
214+ self .assertEqual (dti .is_quarter_end [0 ], False )
215+ self .assertEqual (dti .is_quarter_end [30 ], False )
216+ self .assertEqual (dti .is_quarter_end [89 ], True )
217+ self .assertEqual (dti .is_quarter_end [364 ], True )
218+ self .assertEqual (dti .is_year_end [0 ], False )
219+ self .assertEqual (dti .is_year_end [364 ], True )
220+
221+ # GH 11128
222+ self .assertEqual (dti .weekday_name [4 ], u'Monday' )
223+ self .assertEqual (dti .weekday_name [5 ], u'Tuesday' )
224+ self .assertEqual (dti .weekday_name [6 ], u'Wednesday' )
225+ self .assertEqual (dti .weekday_name [7 ], u'Thursday' )
226+ self .assertEqual (dti .weekday_name [8 ], u'Friday' )
227+ self .assertEqual (dti .weekday_name [9 ], u'Saturday' )
228+ self .assertEqual (dti .weekday_name [10 ], u'Sunday' )
229+
230+ self .assertEqual (Timestamp ('2016-04-04' ).weekday_name , u'Monday' )
231+ self .assertEqual (Timestamp ('2016-04-05' ).weekday_name , u'Tuesday' )
232+ self .assertEqual (Timestamp ('2016-04-06' ).weekday_name ,
233+ u'Wednesday' )
234+ self .assertEqual (Timestamp ('2016-04-07' ).weekday_name , u'Thursday' )
235+ self .assertEqual (Timestamp ('2016-04-08' ).weekday_name , u'Friday' )
236+ self .assertEqual (Timestamp ('2016-04-09' ).weekday_name , u'Saturday' )
237+ self .assertEqual (Timestamp ('2016-04-10' ).weekday_name , u'Sunday' )
238+
239+ self .assertEqual (len (dti .year ), 365 )
240+ self .assertEqual (len (dti .month ), 365 )
241+ self .assertEqual (len (dti .day ), 365 )
242+ self .assertEqual (len (dti .hour ), 365 )
243+ self .assertEqual (len (dti .minute ), 365 )
244+ self .assertEqual (len (dti .second ), 365 )
245+ self .assertEqual (len (dti .microsecond ), 365 )
246+ self .assertEqual (len (dti .dayofweek ), 365 )
247+ self .assertEqual (len (dti .dayofyear ), 365 )
248+ self .assertEqual (len (dti .weekofyear ), 365 )
249+ self .assertEqual (len (dti .quarter ), 365 )
250+ self .assertEqual (len (dti .is_month_start ), 365 )
251+ self .assertEqual (len (dti .is_month_end ), 365 )
252+ self .assertEqual (len (dti .is_quarter_start ), 365 )
253+ self .assertEqual (len (dti .is_quarter_end ), 365 )
254+ self .assertEqual (len (dti .is_year_start ), 365 )
255+ self .assertEqual (len (dti .is_year_end ), 365 )
256+ self .assertEqual (len (dti .weekday_name ), 365 )
251257
252258 dti = DatetimeIndex (freq = 'BQ-FEB' , start = datetime (1998 , 1 , 1 ),
253259 periods = 4 )
0 commit comments