0

I can't figure out how to parse this string to date time correctly, no matter what format I try it says time data does not match format.

# df['_01_FISCPER'] is like '2018011' i.e November 2018
df['FISCPER_DT'] = pd.to_datetime(df['_01_FISCPER'], format='%yyyy%mmm')

1 Answer 1

1

format= takes an strftime compatible format string. %yyyy%mmm would match a 2-character year, the literal yyy, then a 2-character month and the literal mm.

For 2018011, ie. YYYY0MM, you might want to try format='%Y0%m'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.