Pandas pandas pandas project in Data Science course
My code is not working for test case 3. I tried to revise the code again and again but I don’t know what is wrong here. Can anybody give me a clue where my code went wrong? Also does anybody know what is the test case 3? https://code.sololearn.com/c6w3kYK2HrOu/?ref=app
3/3/2021 1:45:35 PMMir Abir Hossain
14 AnswersNew Answer
you're welcome. keep practicing.
if n1 or n2 is null you will have an error on line 25 or line 26. I suggest you, before calculating the means to first test if those numbers are not null. I suppose that in this test, one of your variables n1 or n2 will be null.
Here is my solution: https://www.sololearn.com/Discuss/2730223/ Could anyone help?
Mir Abir Hossain how did you fix it? Can you show please?
Mir Abir Hossain figured it out thanks.
John Robotane thanks a lot for the suggestion ^_^ Let me try
John Robotane it worked. Thanks <3
Zach Z I have fixed the code above. You can click and see it. Probably it is understandable. If not, then I will explain again.
Hey Mir Abir Hossain nvm i saw the issie but its still not solving #3?
Zach Z can you show me your code?
Zach Z welcome
import numpy as np n = int(input()) points =  for i in range(n): x, y = input().split() x, y = [float(i) for i in [x,y]] points.extend([[x,y]]) a = np.array([0,0]) b = np.array([2,2]) grp1 =  grp2 =  for j in points: d1 = np.linalg.norm(a-j) d2 = np.linalg.norm(b-j) if d1 > d2 : grp2.extend(j) else : grp1.extend(j) grp1 = np.array(grp1) x= int(grp1.size/2) grp1 = np.reshape(grp1,(x,2)) mask = grp1.mean(axis=0) grp2 = np.array(grp2) y= int(grp2.size/2) grp2 = np.reshape(grp2,(y,2)) mask2 = grp2.mean(axis=0) print(mask.round(2)) print(mask2.round(2)) hi every one I tried this but I got the same error, in case number 3, I don't know what to do ? if any one could help me pass it, I'll be happy.
#THANKS John Robotane n = int(input()) import numpy as np def eudt(lista,listb): lista,listb=np.array(lista), np.array(listb) diff=lista-listb return ((diff**2)+(diff**2))**0.5 w=np.zeros((n,2)) for i in range(n): w[i,]=[float(j) for j in input().split()] distances=np.zeros((n,2)) for i in range(n): distances[i,]=[eudt(w[i,],[0,0]),eudt(w[i,],[2,2])] team0=w[(distances[:,0]<=distances[:,1]),] team2=w[(distances[:,0]>distances[:,1]),] if sum(distances[:,0]<=distances[:,1])!=0: zeromn=np.around(team0.mean(axis=0),2) if sum(distances[:,0]>distances[:,1])!=0: twoavg=np.around(team2.mean(axis=0),2) if sum(distances[:,0]<=distances[:,1])==0: zeromn=None elif sum(distances[:,0]>distances[:,1])==0: twoavg=None else: pass print(zeromn) print(twoavg)
Thank you Airat Halitov🔥