I am unable to change the date into the float format. When I use them I get the following error.
return array(a, dtype, copy=False, order=order) ValueError: could not convert string to float: '24/03/2019'
I am unable to change the date into the float format. When I use them I get the following error.
return array(a, dtype, copy=False, order=order) ValueError: could not convert string to float: '24/03/2019'
You can't parse a string like 24/03/2019
info a float/int
since it has non numeric chars
.
My advice would be to parse that string date into a datetime:
from datetime import datetime
# without time
datetime_obj = datetime.strptime('24/03/2019', '%d/%m/%Y')
print(datetime_obj.date())
# with time
date_time_str = '2018-06-29 08:15:27.243860'
date_time_obj = datetime.datetime.strptime('2019-03-24 08:15:27.243860', '%Y-%m-%d %H:%M:%S.%f')
print(datetime_obj.date())
If you really need to parse it into a numeric value and the dates are all like the one you provided, 24/03/2019
, I would advise to use a regex and parse it into an int instead of float.