Pandas Pandas Pandas
I am outputting the correct centroids for the test cases, but they are not being taken as correct. Can someone advise? n = int(input()) import numpy as np X = [] for i in range(n): X.append([float(x) for x in input().split()]) #print(X) #calculate distance between points and the origin dist_origin = [] for i in range(n): y = np.sqrt((X[i][0])**2 + (X[i][1]**2)) dist_origin.append(float(y)) #calculate distance between points and second centroid dist_cen = [] for i in range(n): y = np.sqrt((X[i][0] - 2.0)**2 + (X[i][1] - 2.0)**2) dist_cen.append(float(y)) #assign points to centroid origin = [] cen = [] for i in range(n): if dist_origin[i] < dist_cen[i]: origin.append(X[i]) elif dist_origin[i] > dist_cen[i]: cen.append(X[i]) elif dist_origin[i] == dist_cen[i]: origin.append(X[i]) else: print(none) #calculate new centroids from assigned data points x = len(origin) xsum, ysum = 0,0 for i in range(x): xsum += origin[i][0] ysum += origin[i][1] xavg = round(xsum / x, 2) yavg = round(ysum / x, 2) cen1 = [xavg, yavg] x = len(cen) xsum, ysum = 0,0 for i in range(x): xsum += cen[i][0] ysum += cen[i][1] xavg = round(xsum / x, 2) yavg = round(ysum / x, 2) cen2 = [xavg, yavg] print(cen1) print(cen2)