#"['LABEL'] not found in axis"

2 messages · Page 1 of 1 (latest)

outer briar
#

`import tensorflow
import keras
import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model
from sklearn.utils import shuffle

data = pd.read_csv("student-mat.csv", sep=";")

data = data[["G1", "G2", "G2", "studytime", "failures", "absences"]]

predict = "G3"

x = np.array(data.drop([predict], axis = 1))
y = np.array(data[predict])

x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(x, y, test_size = 0.1)

linear = linear_model.linearRegression()

linear.fit(x_train, y_train)

acc = linear.score(x_test, y_test)
print(acc)`

#

the error: `Traceback (most recent call last):
File "C:\Users\akats.HOT_CHOCOLATE\PycharmProjects\tensorEnv\tensor.py", line 15, in <module>
x = np.array(data.drop([predict], axis = 1))
File "C:\Users\akats.HOT_CHOCOLATE\anaconda3\lib\site-packages\pandas\util_decorators.py", line 331, in wrapper
return func(*args, **kwargs)
File "C:\Users\akats.HOT_CHOCOLATE\anaconda3\lib\site-packages\pandas\core\frame.py", line 5399, in drop
return super().drop(
File "C:\Users\akats.HOT_CHOCOLATE\anaconda3\lib\site-packages\pandas\util_decorators.py", line 331, in wrapper
return func(*args, **kwargs)
File "C:\Users\akats.HOT_CHOCOLATE\anaconda3\lib\site-packages\pandas\core\generic.py", line 4505, in drop
obj = obj._drop_axis(labels, axis, level=level, errors=errors)
File "C:\Users\akats.HOT_CHOCOLATE\anaconda3\lib\site-packages\pandas\core\generic.py", line 4575, in _drop_axis
raise KeyError(f"{labels} not found in axis")
KeyError: "['G3'] not found in axis"

Process finished with exit code 1`