Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12171

“TypeError: type ‘DataFrame’ is not subscriptable” when creating a DataFrame in pandas

$
0
0

Type Error

I’m attempting to create a DataFrame in pandas using the following code:

The DataFrame is supposed to have two columns: “y_test” and “y_pred”. The “y_test” column should contain the test data from my model, and the “y_pred” column should contain the predicted values from my model.

However, when I run this code, I get a TypeError: type 'DataFrame' is not subscriptable. I’m not sure why this is happening. I thought that the syntax I used to create the DataFrame was correct.

df_pred_test = pd.DataFrame[    {'y_test': y_test,'y_pred': model.predict(X_test)    }]df_pred_test.head()

Viewing all articles
Browse latest Browse all 12171

Trending Articles