0

I get the following error when passing a pandas dataframe to scikitlearn algorithms:

invalid literal for float(): 2.,3

How do I find the row or column with the problem in order to fix or eliminate it? Is there something like df[df.isnull().any(axis=1)] for a specific value (in my case I guess 2.,3)?

2
  • 1
    Do one of your columns have 2.,3 as a cell value? Try to_numeric() or print df.dtypes to see what type of data pandas is inferring. It probably says 'object'. Commented May 22, 2017 at 20:33
  • Yes correct, df.dtypes gives me object for one of the columns that should be float64. How do I find out where is the problematic cell? Commented May 22, 2017 at 22:02

1 Answer 1

1

If you know what column it is, you can use

df[df.your_column == 2.,3]

then you'll get all rows where the specified column has a value of 2.,3

You might have to use

df[df.your_column == '2.,3'] 
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.