I've selected the features from my data set and then when I try to select those features from my data set, I get this error. Why is this happening?

    dataset = pd.read_csv('Banking Dataset.csv')
    LabelEncoder1 = LabelEncoder()
    independent_variables[:,1] = LabelEncoder1.fit_transform(independent_variables[:,1])
    LabelEncoder2 = LabelEncoder()
    independent_variables[:,2] = LabelEncoder2.fit_transform(independent_variables[:,2])

    onehotencoder = OneHotEncoder(categorical_features=[1])
    independent_variables = onehotencoder.fit_transform(independent_variables).toarray()

    X_train, X_test, Y_train,Y_test = train_test_split(independent_variables,target_values  ,test_size=0.25,random_state=0)

    c = DecisionTreeClassifier(min_samples_split=100)
    features =["CreditScore","Geography","Gender","Age","Tenure","Balance","NumOfProducts","HasCrCard","IsActiveMember","EstimatedSalary"]
    X = X_train(features)


FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. X_train=X_train[features] Traceback (most recent call last):


IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Process finished with exit code 1

2 Answers

Majo_Jose On

Use the below


instead of


use [] when calling a numpy array

mathew gunther On

the error code is saying that the specific line


should have square braces [] around features intead of (). i.e.