import polars as pl
df = pl.DataFrame(['2023-08-01T06:13:24.448409',
'2023-08-01T07:29:34.491027'])
print(df.with_columns(pl.col('column_0').str.strptime(pl.Date,'%Y-%m-%d')))
So I have the following mass of code, and for some ungodly reason I cant for the death of me extract the date from those given strings.
In the following example I keep getting the error
exceptions.ComputeError: strict date parsing failed for 2 value(s) (2 unique): ["2023-08-01T06:13:24.448409", "2023-08-01T07:29:34.491027"]
Any ideas on how can I extract the string from such format of datetime? And why I get this error?
>Solution :
To parse a datetime upfront you’ll need to provide the full format (date & time) initially then retrieve the date part afterwards. Try the following format:
'%Y-%m-%dT%H:%M:%S.%f'