值的长度与索引的长度不匹配

时间:2018-11-01 08:45:43

标签: python python-3.x machine-learning

您好,我正在编写代码以聚簇和合并社区。我收到以下错误“值的长度与索引的长度不匹配”

我的代码是

kclusters = 5

scarborough_grouped_clustering = scarborough_grouped.drop('Neighborhood', 1)

# run k-means clustering
kmeans = KMeans(n_clusters=kclusters, random_state=0).fit(scarborough_grouped_clustering)

# check cluster labels generated for each row in the dataframe
kmeans.labels_[0:10] 

scarborough_merged = b

# add clustering labels
scarborough_merged['Cluster Labels'] = kmeans.labels_

scarborough_merged = scarborough_merged.join(neighborhoods_venues_sorted.set_index('Neighborhood'), on='Neighborhood')

scarborough_merged.head()

错误详细信息:

ValueError     
   3997     if len(data) != len(index):
-> 3998         raise ValueError('Length of values does not match length of ' 'index')
   3999 `enter code here`
   4000     if isinstance(data, ABCIndexClass) and not copy:

ValueError: Length of values does not match length of index

0 个答案:

没有答案