Мой 3D-кластерный анализ K-Means не распознает импортированные данные Excel - PullRequest
0 голосов
/ 30 марта 2020

Я попробовал 3D K означает Кластерный анализ в Python, импортируя три столбца, которые меня интересуют, в кластеризацию из Excel, используя следующий код:

#loading the dataset
dataset = pd.read_excel('Dissertation_Cluster1.xlsx')
X = dataset.iloc[:,[1,2,3]].values #The three columns to analyse
y_set = dataset.iloc[:,[0]].values 

from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters = 5, init = 'k-means++', max_iter=1000, n_init = 100, random_state=0)
y_kmeans = kmeans.fit_predict(X)

, и он возвращает следующую ошибку:

  File xxx, line 15, in <module>
    f1 = data['Loans/Assets (%)'].values
  File xxx, line 2800, in __getitem__
    indexer = self.columns.get_loc(key)
  File xxx, line 2648, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Loans/Assets (%)'

Где «Кредиты / Активы (%)» - это один из трех столбцов, которые я импортировал из Excel.

Кто-нибудь знает, в чем моя ошибка? Я новичок в Python и буду признателен за помощь! Спасибо:)

...