I'm stuck on this and looking for community help. I have a few columns within a dataframe that are labeled as objects but would like to convert to datetime. All columns have year,month,day criteria.
time = np.array(['time1','time2','time3'])
def cols_to_datetime(df):
cols_to_datetime = time
for col in cols_to_datetime:
df[col] = pd.to_datetime(df[col])
return df
Although all have year, month, day i'm receiving this error
ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing
df -
time1 time2 time3
2020-06-06 20:01:10.327 2020-06-06 22:08:14.832 2020-06-06
There may be nulls in the df that would need to be skipped.
I did test without them and didn't have luck. So I'm not quite sure why this approach doesn't work. Thanks!
timefor variable names... plus it will be data specific