@@ -83,7 +83,7 @@ def test_dt_namespace_accessor(self):
8383 ok_for_period = ok_for_base + ['qyear' ]
8484 ok_for_dt = ok_for_base + ['date' ,'time' ,'microsecond' ,'nanosecond' , 'is_month_start' , 'is_month_end' , 'is_quarter_start' ,
8585 'is_quarter_end' , 'is_year_start' , 'is_year_end' , 'tz' ]
86- ok_for_dt_methods = ['to_period' ,'to_pydatetime' ,'tz_localize' ,'tz_convert' , 'normalize' ]
86+ ok_for_dt_methods = ['to_period' ,'to_pydatetime' ,'tz_localize' ,'tz_convert' , 'normalize' , 'strftime' ]
8787 ok_for_td = ['days' ,'seconds' ,'microseconds' ,'nanoseconds' ]
8888 ok_for_td_methods = ['components' ,'to_pytimedelta' ]
8989
@@ -135,6 +135,16 @@ def compare(s, name):
135135 expected = Series (DatetimeIndex (s .values ).tz_localize ('UTC' ).tz_convert ('US/Eastern' ),index = s .index )
136136 tm .assert_series_equal (result , expected )
137137
138+ s = Series (date_range ('20130101' , periods = 5 ))
139+ result = s .dt .strftime ('%Y/%m/%d' )
140+ expected = ['2013/01/01' , '2013/01/02' , '2013/01/03' , '2013/01/04' , '2013/01/05' ]
141+ self .assertEqual (result , expected )
142+
143+ s .iloc [0 ] = pd .NaT
144+ result = s .dt .strftime ('%Y/%m/%d' )
145+ expected = ['NaT' , '2013/01/02' , '2013/01/03' , '2013/01/04' , '2013/01/05' ]
146+ self .assertEqual (result , expected )
147+
138148 # timedeltaindex
139149 for s in [Series (timedelta_range ('1 day' ,periods = 5 ),index = list ('abcde' )),
140150 Series (timedelta_range ('1 day 01:23:45' ,periods = 5 ,freq = 's' )),
0 commit comments