这是我的代码。
from sklearn.cluster import DBSCAN
dbscan = DBSCAN(random_state=111)
dbscan.fit(data3)
data3是一个pandas数据帧:
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
有什么问题?
答案 0 :(得分:9)
问题是一个错误。它不适用于pandas数据帧。解决方案是将pandas数据帧转换为numpy数组:
data3 = np.array(data3)