0

I got CSV files to train but while training error is coming.

ValueError: could not convert string to float: 'CBH'

enter image description here

4
  • 1
    Help us help you - share your code Commented Aug 28, 2020 at 10:32
  • Column B contains words like CBH, which is not a number. You need to convert only columns I and J. Commented Aug 28, 2020 at 10:34
  • so in order to train the above data set what should i do? Commented Aug 28, 2020 at 10:38
  • What do you understand from that error message? Please provide a minimal reproducible example. Commented Aug 28, 2020 at 10:40

2 Answers 2

1

Label Encoding can turn the available values into their own unique value.

import pandas as pd
import sklearn

df = pd.read_csv('file-path')

le = sklearn.preprocessing.LabelEncoding()
le.fit(df['code'])
df = df[le.transform(df['code'])]

# change back
df = df[le.inverse_transform(df['code'])]

Sklearn Label Encoding Documentation

Sign up to request clarification or add additional context in comments.

Comments

0

obviously You try to convert values of row "B" to float. And the Value "CBH" can not be converted to a floating point number.

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.