close

[Solved] Pandas : TypeError: float() argument must be a string or a number

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Pandas : TypeError: float() argument must be a string or a number in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Pandas : TypeError: float() argument must be a string or a number Error Occurs?

Today I get the following error Pandas : TypeError: float() argument must be a string or a number in python.

How To Solve Pandas : TypeError: float() argument must be a string or a number Error ?

  1. How To Solve Pandas : TypeError: float() argument must be a string or a number Error ?

    To Solve Pandas : TypeError: float() argument must be a string or a number Error

    TypeError: float() argument must be a string or a number, not 'Timestamp'

  2. Pandas : TypeError: float() argument must be a string or a number

    To Solve Pandas : TypeError: float() argument must be a string or a number Error

    TypeError: float() argument must be a string or a number, not 'Timestamp'

Solution 1

IIUC you need exclude column date also:

columns = [c for c in columns if c not in ["test", 'date']]

because error:

TypeError: float() argument must be a string or a number, not ‘Timestamp’

Solution 2

A solution which keeps the date(time) column:

data['date'] = pd.to_numeric(pd.to_datetime(data['date']))

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read