I want to remove the microseconds from index.
My index is like this:
DatetimeIndex(['2003-11-20 13:07:40.895000+00:00',
'2003-11-20 13:16:13.039000+00:00',
'2003-11-20 13:24:44.868000+00:00',
'2003-11-20 13:33:17.013000+00:00',
'2003-11-20 13:41:49.158000+00:00',
'2003-11-20 13:50:20.987000+00:00',
'2003-11-20 13:58:53.132000+00:00',
'2003-11-20 14:07:24.961000+00:00',
'2003-11-20 14:15:57.106000+00:00',
'2003-11-20 14:24:28.935000+00:00',
...
'2003-12-04 19:28:56.025000+00:00',
'2003-12-04 19:37:27.854000+00:00',
'2003-12-04 19:45:59.999000+00:00',
'2003-12-04 19:54:32.143000+00:00',
'2003-12-04 20:03:03.972000+00:00',
'2003-12-04 20:11:36.117000+00:00',
'2003-12-04 20:20:07.946000+00:00',
'2003-12-04 20:28:40.091000+00:00',
'2003-12-04 20:37:11.920000+00:00',
'2003-12-04 20:45:44.065000+00:00'],
dtype='datetime64[ns, UTC]'
And I want to remove the microseconds in order to have something like this only: '2003-12-04 20:45:44'
I do not want to convert it to string, as it is needed to remain datetime because it is the index of the dataframe.
I have been searching for this, but I only found this, which does not work:
df.index.replace(microsecond=0, inplace = True)
Can you help me please?