簡體   English   中英

AttributeError:“numpy.ndarray”對象在 Python 中沒有屬性“index”

[英]AttributeError: 'numpy.ndarray' object has no attribute 'index' in Python

我想創建一個數據幀的索引等於另一個數據幀的索引。

y_test_proba.index = X_test.index

但它有一個錯誤。

AttributeError: 'numpy.ndarray' object has no attribute 'index'

如何解決這個錯誤?

將數組強制為 Pandas DataFrame 將使您能夠訪問索引。

X_test_df = pandas.DataFrame(X_test)
X_test_df.index

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM