沒有屬性這是我的代碼:熊貓 - 浮動對象有九
X_train, X_test, y_train, y_test = train_test_split(sing.ix[:-10], y.ix[:-10].T.corr(), test_size=0.2)
,但我得到這個錯誤:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-78-32ea47dd4970> in <module>()
1 # Split data into train and test leaving last ten (10) rows for the final evaluation
----> 2 X_train, X_test, y_train, y_test = train_test_split(sing.ix[:-10], y.ix[:-10].T.corr(), test_size=0.2)
AttributeError: 'float' object has no attribute 'ix'
有人能解釋如何解決呢?非常感謝!
它看起來像你期望一個熊貓數據幀,但有一個浮動,而不是 –
'sing'和/或者「y」是一個浮點數。重新審視這些變量的創建,以確保它們符合您的期望。 – 3novak
謝謝,但是我應該如何將浮動對象轉換爲? – Zucchini