result = X_train.join(y_train) result.head()AttributeError Traceback (most recent call last) <ipython-input-32-957a4f0008b1> in <module> ----> 1 result = X_train.join(y_train) 2 result.head() AttributeError: 'numpy.ndarray' object has no attribute 'join'
时间: 2023-05-21 19:04:04 浏览: 178
这个错误是因为 numpy.ndarray 对象没有 join() 方法。如果你想将 X_train 和 y_train 拼接在一起,可以使用 numpy.concatenate() 方法。例如:result = numpy.concatenate((X_train, y_train), axis=1)。然后,你可以使用 result.head() 方法查看结果的前几行。
相关问题
Exception in Tkinter callback Traceback (most recent call last): File "E:\Anaconda3\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "<ipython-input-9-c46edc755222>", line 185, in <lambda> command=lambda key=key: analyze_and_show_result(key)) File "<ipython-input-9-c46edc755222>", line 166, in analyze_and_show_result result = model_analysis(model_name) File "<ipython-input-9-c46edc755222>", line 69, in model_analysis X = data.iloc[:, :-1] AttributeError: 'numpy.ndarray' object has no attribute 'iloc'
这个错误是由于你在代码中使用了一个 numpy 数组,而这个数组没有 iloc 属性。iloc 是 pandas.DataFrame 和 pandas.Series 所具有的方法,用于选取数据集中某些行和列。你需要将 numpy 数组转换成 pandas.DataFrame 或者 pandas.Series 才能使用 iloc 方法。
AttributeError Traceback (most recent call last) <ipython-input-26-7401c2f31978> in <module>
It seems like you are trying to run some code in Python and getting an `AttributeError`. Can you please provide more information about the error, such as the full traceback and the code that you are running?
阅读全文