I have a dataframe where one column is a datetime in <M8[ns]
datatype. However, when I use unique()
it gives me another datatype:
array(['2014-10-27T00:00:00.000000000', '2015-01-28T00:00:00.000000000',
'2015-04-28T00:00:00.000000000', '2015-07-22T00:00:00.000000000',
'2015-10-28T00:00:00.000000000', '2016-01-27T00:00:00.000000000',
'2016-04-27T00:00:00.000000000', '2016-07-27T00:00:00.000000000',
'2016-10-26T00:00:00.000000000', '2017-02-01T00:00:00.000000000',
'2017-05-03T00:00:00.000000000', '2017-08-02T00:00:00.000000000',
'2017-11-03T00:00:00.000000000', '2018-02-02T00:00:00.000000000',
'2018-05-02T00:00:00.000000000', '2018-08-01T00:00:00.000000000',
'2018-11-05T00:00:00.000000000', '2019-01-30T00:00:00.000000000',
'2019-05-01T00:00:00.000000000'], dtype='datetime64[ns]')
Here says it's the same format, but when I try this solution to change datetime format to date it gives me an error:
df["fecha"].date()
AttributeError: 'Series' object has no attribute 'datetime'
There are plenty of solution from string to datetime/date, but I'm looking for a more straightforward solution (datetime to date).