BUG: Fix #13149 and ENH: 'copy' param in Index.astype() by pijucha · Pull Request #13209 · pandas-dev/pandas (original) (raw)
An example from tests (nb. it failed assert_index_equal
with pyhton2.7):
In [2]: idx = DatetimeIndex(['2016-05-16', 'NaT', NaT, np.NaN])
In [3]: idx Out[3]: DatetimeIndex(['2016-05-16', 'NaT', 'NaT', 'NaT'], dtype='datetime64[ns]', freq=None)
In [4]: idx2 = idx.astype(str)
In [5]: idx2 Out[5]: Index([u'2016-05-16', u'NaT', u'NaT', u'NaT'], dtype='object')
In [7]: type(idx2[0]) Out[7]: str
In [8]: type(idx2[1]) Out[8]: unicode
# class DatetimeIndex:
def _format_native_types(self, na_rep=u('NaT'),
date_format=None, **kwargs):