I have a dataframe with an index that also contains the Hour:second:... but instead I just want it to contain the date as year, month, day.
Is it possible for the index to still be a DateTimeIndex but contain only year, month, day?
The current index looks like:
my_index = DatetimeIndex(['2017-08-25', '2017-08-24', '2017-08-23', '2017-08-22',
'2017-08-21', '2017-08-20', '2017-08-19', '2017-08-18',
'2017-08-17', '2017-08-16',
...
'2015-07-19', '2015-07-18', '2015-07-17', '2015-07-16',
'2015-07-15', '2015-07-14', '2015-07-13', '2015-07-12',
'2015-07-11', '2015-07-10'],
dtype='datetime64[ns]', length=778, freq=None)
I could do:
only_date_index = [el.date() for el in my_index]
But then if I want to use the resample function in pandas I get the error: TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'.