@@ -83,7 +83,7 @@ def test_dt_namespace_accessor(self):
83
83
ok_for_period = ok_for_base + ['qyear' ]
84
84
ok_for_dt = ok_for_base + ['date' ,'time' ,'microsecond' ,'nanosecond' , 'is_month_start' , 'is_month_end' , 'is_quarter_start' ,
85
85
'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' ]
87
87
ok_for_td = ['days' ,'seconds' ,'microseconds' ,'nanoseconds' ]
88
88
ok_for_td_methods = ['components' ,'to_pytimedelta' ]
89
89
@@ -135,6 +135,16 @@ def compare(s, name):
135
135
expected = Series (DatetimeIndex (s .values ).tz_localize ('UTC' ).tz_convert ('US/Eastern' ),index = s .index )
136
136
tm .assert_series_equal (result , expected )
137
137
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
+
138
148
# timedeltaindex
139
149
for s in [Series (timedelta_range ('1 day' ,periods = 5 ),index = list ('abcde' )),
140
150
Series (timedelta_range ('1 day 01:23:45' ,periods = 5 ,freq = 's' )),
0 commit comments