Error converting string to float using fit_transform

python

#1

I am geting the error mensage:

array = np.array(array, dtype=dtype, order=order, copy=copy) ValueError: could not convert string to float: ‘Pass w/ Conditions’

Even using fit_transform, the code:

import numpy as np
import pandas as pd
from sklearn.cross_validation import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, classification_report
from sklearn.preprocessing import LabelEncoder
from sklearn import tree

train = pd.read_csv(r’D:\SamuelCarvalho\Google Drive\13º Semestre\Tópicos especiais 1\Aplicação de Machine Learning\Entrega 4 (final)\Base de dados gerada\food-inspections.csv’, engine=‘python’, sep=’;’)
print("\nDimensões: {0}".format(train.shape))
print("\nCampos: {0}".format(train.keys()))
print(train.describe(), sep=’\n’)

X = train.values[:, 1:5]
Y = train.values[:,0]

X_train, X_test, y_train, y_test = train_test_split( X, Y, test_size = 0.3, random_state = 0)

le = LabelEncoder()
y_train = le.fit_transform(train.iloc[:,(train.shape[1] - 1)])

train_tree = DecisionTreeClassifier(random_state=0)
train_tree.fit(X_train, y_train)