Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data Type conversion error
#1
When trying to convert a column to datetime format I get this error.

Error:
|Could not convert object to NumPy datetime|
I am trying the below:
X_test = pd.DataFrame(np.array(
    [['2020-04-03T00:00:00.000000000'],
       ['2020-04-07T00:00:00.000000000'],
       ['2020-04-06T00:00:00.000000000'],
       ...,
       ['2020-04-01T00:00:00.000000000'],
       ['2020-04-03T00:00:00.000000000'],
       ['2020-03-27T00:00:00.000000000']], dtype='datetime64[ns]'))

X_test.columns = ["Merged"]
X_test['Merged'] = pd.to_date(X_test['Merged'])
X_test['Merged'] = X_test['Merged'].map(dt.datetime.toordinal)
Please can you suggest me?

GITHUB:
https://github.com/rajeevjagatap/Python_...nalysis.py
Reply


Messages In This Thread
Data Type conversion error - by rajeevjagatap - Apr-14-2020, 04:01 PM
RE: Data Type conversion error - by Larz60+ - Apr-14-2020, 04:28 PM
RE: Data Type conversion error - by rajeevjagatap - Apr-15-2020, 03:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wrong type error rowan_bradley 6 1,234 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Type Error: Unsupported Operand jhancock 2 1,210 Jul-22-2023, 11:33 PM
Last Post: jhancock
  I need to add data types to cython conversion python to c Good_AI_User 1 1,017 Aug-19-2022, 07:52 AM
Last Post: Gribouillis
  Python Anytree - Is not of type 'NodeMixin' error georgebijum 3 2,099 May-05-2022, 01:43 PM
Last Post: Gribouillis
  Incorrect Type Error milkycow 4 2,919 Jun-25-2021, 06:04 AM
Last Post: milkycow
  pandas.errors.ParserError: Error tokenizing data. C error: Expected 9 fields in line Anldra12 9 15,378 Jun-15-2021, 08:16 AM
Last Post: Anldra12
Star Type Error: 'in' object is not callable nman52 3 3,419 May-01-2021, 11:03 PM
Last Post: nman52
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,099 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  blank graph with matplotlib from a csv file / data type issue arsentievalex 0 1,959 Apr-06-2021, 10:08 AM
Last Post: arsentievalex
  Type Error in Python MarcusB 3 2,588 Mar-30-2021, 06:34 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020