1

I am unable to convert a string in the format 'YYYYMMDD' to a datetime object due to an error.

OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1-01-01 00:00:00

Here is some code snippets I am trying: enter image description here

When I try to do:

data.move_date = pd.to_datetime(data.move_date)

I get the above error. Does anyone know how to fix this? Is this a bug? I did the same exact operation with another column that was in the string format and it worked perfectly.

0

1 Answer 1

2

You can try this:

Adding @COLDSPEED answer

data['Dates'] = pd.to_datetime((data.move_data).apply(str),format='%Y%m%d', errors='coerce')
Sign up to request clarification or add additional context in comments.

4 Comments

pd.to_datetime(..., format='%Y%m%d', errors='coerce')
@COLDSPEED, that worked thank you! So I'm guessing what we did was ignore all problematic rows. Is there a way to view which rows these are??
@codebrotherone usingdf[pd.to_datetime(..., format='%Y%m%d', errors='coerce') .isnull()] to search back you original df
@codebrotherone if the answer helped can you plz upvote the answer plz? :)

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.