Search code examples
pythonk-means

TypeError: 'list' object is not callable for KMeans


I am trying to run the following code which has been running throughout my notebook without issues for different categories:

model = KMeans(n_clusters = 3, random_state= 123) 
model.fit(deos_scaled_data_1)
df_key_kpis_deos['Cluster_1a'] = list(model.labels_)

But I am getting the following error message: TypeError: 'list' object is not callable

The exact same code has run for different df's, so Im struggling to understand what is different here. What am I going wrong?


Solution

  • The most probable thing here is that in code before your third line you assigned a variable with the name list and then you override the original list function.