Issue
I have a dataframe df and has a column by name timeframe of dtype object
column_a | timeframe |
---|---|
One | nov-21 |
Two | jun-90 |
I would like to convert timeframe column to date type but this conversion fails with error Out of bounds nanosecond timestamp: 1-11-21 00:00:00
df['timeframe'] = pd.to_datetime(df['Date'])
Solution
Specify the format:
df['timeframe'] = pd.to_datetime(df['timeframe'], format="%b-%y", errors="coerce")
Answered By - not_speshal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.