+ 1
Someone can help me with my Data Science Pandas Pandas Pandas?
I try solve this exercise, but i Didn't It. There is hidden test case, and i do not know what is It?. Thanks for the answers
5 Respostas
+ 2
import numpy as np
n = int(input())
def means(centroid):
for c in centroid:
npc = np.array(c)
print(np.round(np.mean(npc,0),2))
print(end="")
def euclidean(p,q):
if p is None or q is None:
return None
x = (p[0] - q[0])**2.
y = (p[1] - q[1])**2.
return np.round(np.sqrt(x + y),2)
def indexMin(d1,d2):
index = 1
if d1 is None and d2 is None:
return -1
if d2 is None or d1 <= d2:
index = 0
return index
centroids = np.array([[0,0],[2,2]])
points = []
for i in range(0,n):
x,y = [float(x) if x is not None else None for x in input().split()]
if x is None and y is not None:
points.append(None)
else:
points.append([x,y])
npoints = np.array(points)
new_centroids = [ [], [] ]
if points is None:
print(None)
quit()
for point in points:
dist = euclidean(point,centroids[0])
dist2 = euclidean(point,centroids[1])
index = indexMin(dist,dist2)
if index>-1:
new_centroids[index].append(point)
if new_centroids is None:
+ 1
can you save your code and share its link?
0
Yeah of course
- 1
You have some little mistakes, but no problem ...
Just look at my code:
https://code.sololearn.com/cFd4zts1giuh/?ref=app
But seriously look how mine and your code work and see the difference to understand your mistakes 😄.