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

  • When I use .reset_index, as recommended, I get the following error: --------------------------------------------------------------------------- NameError Traceback (most recent call last) in ----> 1 Confirmed_Date_test.reset_index(inplace=true) NameError: name 'true' is not defined – Jonathan Ambriz Apr 29 '20 at 20:44
  • When I use .reset_index() without inplace parameter, it works. The original error remains the same. – Jonathan Ambriz Apr 29 '20 at 20:46

2 Answers2

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)
Renaud
  • 2,709
  • 2
  • 9
  • 24
0

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