Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
AH HA! I have to make sure the index on the cluster series is the sam…
Browse files Browse the repository at this point in the history
…e as the index on the data
  • Loading branch information
jackmaney committed Jan 12, 2014
1 parent 9f036ef commit 413ed6a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions k_means_plus_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
class KMeansPlusPlus:
def __init__(self,data_frame,k
,columns=None
,max_iterations=None
,tolerance = 1e-5):
,max_iterations=None):
if not isinstance(data_frame,DataFrame):
raise Exception("data_frame argument is not a pandas DataFrame")
elif data_frame.empty:
Expand Down Expand Up @@ -91,7 +90,7 @@ def _get_clusters(self):
if boolean_series[j]
]

self.clusters = Series(cluster_list)
self.clusters = Series(cluster_list,index=self.data_frame.index)

def _compute_new_centers(self):
if self.centers is None:
Expand Down

0 comments on commit 413ed6a

Please sign in to comment.