Error using decision tree regressor I'm new to data science , while i'm implementing decision tree. I'm facing the following error. Where i went wrong;

Sample data in csv is:




x=dataset.iloc[:,:-1].values
y=dataset.iloc[:,:2].values
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
from sklearn.compose import ColumnTransformer
labelencoder_x=LabelEncoder()
x[:,0]=labelencoder_x.fit_transform(x[:,0])
onehotencoder=OneHotEncoder()
columntransformer=ColumnTransformer([('dummy cols',onehotencoder,[0])],remainder='passthrough')
x=columntransformer.fit_transform(x)


from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=1)

from sklearn.tree import DecisionTreeRegressor
regressor=DecisionTreeRegressor(random_state=0)
regressor.fit(x,y)  #Error occurance


Error:
'''
ValueError: could not convert string to float: 'Business Analyst'
'''
The problem is with the y value.

x=dataset.iloc[:,:-1].values -&gt; selecting all columns but last #this one is fine

y=dataset.iloc[:,:2].values -&gt; selecting all columns till 2nd #this one is wrong


Change this to : 

y=dataset.iloc[:,2].values #selecting only 2nd column.