0

I loaded a DataFrame from a csv file and one column contains a date/time string, in order to convert it to an actual date object I am currently doing this:

mydata["date_time"] = pd.to_datetime(mydata["date_time"], errors='raise')

However I feel like there may be a more concise way of doing this but can't find it.

Am I doing things right or is there a better alternative?

0

1 Answer 1

2

I will convert to date time with read_csv

df = pd.read_csv('yourfile.csv', parse_dates=['date_time'])
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.