KeyError Traceback(最后一次调用)
/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3801 尝试:
-> 3802 返回 self._engine.get_loc(casted_key)
3803 除了 KeyError 为 err:
4 帧
pandas/_libs/hashtable_class_helper.pxi 在 pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi 在 pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: '文本'
#加载数据集
data =pd.read_csv('/content/sample_data/california_housing_test.csv')
#将数据集拆分为训练集和测试集
X = 数据 ['文本']
y = 数据 ['标签']
X_train,x_test
y_train,y_test
train_test_split(X,y,test_size==0.2)