Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:无法使用此索引类型执行_usub_uu:<;类别';pandas.core.Index.base.Index'&燃气轮机;_Python - Fatal编程技术网

Python TypeError:无法使用此索引类型执行_usub_uu:<;类别';pandas.core.Index.base.Index'&燃气轮机;

Python TypeError:无法使用此索引类型执行_usub_uu:<;类别';pandas.core.Index.base.Index'&燃气轮机;,python,Python,我正在尝试运行一个关于成人人口普查数据的示例代码。 当我运行这段代码时: X_train, X_test, y_train, y_test = cross_validation.train_test_split(encoded_data[encoded_data.columns - ["Target"]], encoded_data["Target"], train_size=0.70, random_state = 42) scaler = preprocessing.StandardScal

我正在尝试运行一个关于成人人口普查数据的示例代码。 当我运行这段代码时:

X_train, X_test, y_train, y_test = cross_validation.train_test_split(encoded_data[encoded_data.columns - ["Target"]], encoded_data["Target"], train_size=0.70, random_state = 42)
scaler = preprocessing.StandardScaler()
X_train = pd.DataFrame(scaler.fit_transform(X_train.astype("f64")), columns=X_train.columns)
X_test = scaler.transform(X_test.astype("f64"))
我不断地发现这个错误:

  2101     def __sub__(self, other):
   2102         raise TypeError("cannot perform __sub__ with this index type: "
-> 2103                         "{typ}".format(typ=type(self)))
   2104 
   2105     def __and__(self, other):

TypeError: cannot perform __sub__ with this index type: <class 'pandas.core.indexes.base.Index'>
2101定义(自身、其他):
2102 raise TypeError(“无法使用此索引类型执行子索引:”
->2103“{typ}”。格式(typ=type(self)))
2104
2105定义和(自身、其他):
TypeError:无法使用此索引类型执行子索引:
我目前正在使用蟒蛇27

试试这个:

X_test = scaler.transform(X_test.astype("float64"))