Repository: pandas-dev/pandas

Issue:
API: DatetimeIndex.strftime should return an Index
``Index.strftime`` should be returning an ``Index`` and not an array, we do this for other accessors. see https://github.com/pandas-dev/pandas/pull/20103/files#r173622263



```
In [6]: pd.date_range('20130101',periods=3).hour
Out[6]: Int64Index([0, 0, 0], dtype='int64')

In [7]: pd.date_range('20130101',periods=3).strftime('%Y%m%d')
Out[7]: array(['20130101', '20130102', '20130103'], dtype='<U8')
```


Discussion:

Resolving patch:
diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py
--- a/pandas/core/indexes/datetimelike.py
+++ b/pandas/core/indexes/datetimelike.py
@@ -58,12 +58,12 @@ class DatelikeOps(object):
     """ common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex """
 
     def strftime(self, date_format):
-        return np.asarray(self.format(date_format=date_format),
-                          dtype=compat.text_type)
+        return Index(self.format(date_format=date_format),
+                     dtype=compat.text_type)
     strftime.__doc__ = """
-    Convert to string array using specified date_format.
+    Convert to Index using specified date_format.
 
-    Return an array of formatted strings specified by date_format, which
+    Return an Index of formatted strings specified by date_format, which
     supports the same string format as the python standard library. Details
     of the string format can be found in `python string format doc <{0}>`__
 
@@ -74,8 +74,8 @@ def strftime(self, date_format):
 
     Returns
     -------
-    numpy.ndarray
-        NumPy array of formatted strings
+    Index
+        Index of formatted strings
 
     See Also
     --------


Test patch:
diff --git a/pandas/tests/series/test_datetime_values.py b/pandas/tests/series/test_datetime_values.py
--- a/pandas/tests/series/test_datetime_values.py
+++ b/pandas/tests/series/test_datetime_values.py
@@ -355,16 +355,16 @@ def test_strftime(self):
         datetime_index = date_range('20150301', periods=5)
         result = datetime_index.strftime("%Y/%m/%d")
 
-        expected = np.array(['2015/03/01', '2015/03/02', '2015/03/03',
-                             '2015/03/04', '2015/03/05'], dtype=np.object_)
+        expected = Index(['2015/03/01', '2015/03/02', '2015/03/03',
+                          '2015/03/04', '2015/03/05'], dtype=np.object_)
         # dtype may be S10 or U10 depending on python version
-        tm.assert_numpy_array_equal(result, expected, check_dtype=False)
+        tm.assert_index_equal(result, expected)
 
         period_index = period_range('20150301', periods=5)
         result = period_index.strftime("%Y/%m/%d")
-        expected = np.array(['2015/03/01', '2015/03/02', '2015/03/03',
-                             '2015/03/04', '2015/03/05'], dtype='=U10')
-        tm.assert_numpy_array_equal(result, expected)
+        expected = Index(['2015/03/01', '2015/03/02', '2015/03/03',
+                          '2015/03/04', '2015/03/05'], dtype='=U10')
+        tm.assert_index_equal(result, expected)
 
         s = Series([datetime(2013, 1, 1, 2, 32, 59), datetime(2013, 1, 2, 14,
                                                               32, 1)])