2014-12-06 73 views
4

這是我的代碼。dbscan指數超出界限python

from sklearn.cluster import DBSCAN 

dbscan = DBSCAN(random_state=111) 

dbscan.fit(data3) 

DATA3是大熊貓數據框:

 FAC1_2 FAC2_2 
0 -0.227252 -0.685482 
1 0.015251 -0.988252 
2 -0.291176 -0.696146 
3 -0.747702 -0.708030 
4 -0.648103 -0.701741 
5 -0.546777 -0.906151 
6 -0.141553 -0.689223 
7 0.159203 -0.734537 
8 0.345847 -0.900163 
9 -0.049349 -0.700356 
10 0.079924 -0.651371 

我得到以下錯誤:

File "/anaconda/anaconda/lib/python3.4/site-packages/pandas/core/indexing.py", line 1632, in _maybe_convert_indices 
raise IndexError("indices are out-of-bounds") 

IndexError: indices are out-of-bounds 

問題是什麼?

回答

9

問題是一個錯誤。它不適用於熊貓數據框。解決方案是將熊貓數據幀轉換爲numpy數組:

data3 = np.array(data3)