0

I'm having a hard time with pd.to_datetime() in Python 3 on Anaconda. Hopefully it's a simple fix, but it's saying that the issue is the data is a series type and not a DataFrame. Can someone please let me know if there's a quick fix to this?

This is the code that's giving me an error:

pd.to_datetime(Confirmed_Date_test.ObservationDate, errors='coerce', format='%d%m%Y')

This is the error I'm getting:

enter image description here

Here is the code where the data is wrangled:

enter image description here

2
  • When I use .reset_index, as recommended, I get the following error: --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-54-6c150d3816f1> in <module> ----> 1 Confirmed_Date_test.reset_index(inplace=true) NameError: name 'true' is not defined Commented Apr 29, 2020 at 20:44
  • When I use .reset_index() without inplace parameter, it works. The original error remains the same. Commented Apr 29, 2020 at 20:46

2 Answers 2

2

Observation Date is the index of your groupby result. Add a reset index before the pd.todatetime():

Confirmed_Date_test.reset_index(inplace=true)
Sign up to request clarification or add additional context in comments.

Comments

0

It was resolved by adding .to_frame() to the end of the ln 39.

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.