0

im getting an error when trying to convert the date to yyyy-mm-dd

Can anyone help here

import pandas as pd

df = pd.DataFrame({'year': ['20150122', '20160234']})
pd.to_datetime(df,format='%Y-%m-%d')

print(df)

Error

"ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month] is missing"

Expected outcome

0 2015-01-22
1 2016-02-15
Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
Eoin
  • 1

0 Answers0