i have a column with strings which is to convert to datetime (spanish date format)
>>> df['Date'].head()
0 31/10/2019
1 31/10/2019
2 30/10/2019
3 30/10/2019
4 29/10/2019
Name: Date, dtype: object
Convert
>>>pd.to_datetime(df['Date'], dayfirst = True)
>>>df['Date'].head()
0 2019-10-31
1 2019-10-31
2 2019-10-30
3 2019-10-30
4 2019-10-29
Name: Date, dtype: datetime64[ns]
And now I want to sort it by date, and the output converts strangely to:
>>>df['Date'] =df.sort_values(by=['Date'], ascending = True)
>>>df['Date'].head()
0 9443248_19
1 9443205_19
2 9441864_19
3 9441809_19
4 9440310_19
Name: Date, dtype: object
Any clue what happened here? Why the type converts back to object?