+ 2

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

3rd Mar 2021, 1:45 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
14 RĂ©ponses
+ 2
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.
3rd Mar 2021, 2:37 PM
John Robotane
John Robotane - avatar
+ 2
you're welcome. keep practicing.
3rd Mar 2021, 3:22 PM
John Robotane
John Robotane - avatar
+ 1
Here is my solution: https://www.sololearn.com/Discuss/2730223/ Could anyone help?
19th Mar 2021, 2:47 PM
AiratVibe
AiratVibe - avatar
+ 1
Mir Abir Hossain how did you fix it? Can you show please?
20th May 2021, 4:40 PM
Zach Z
+ 1
Mir Abir Hossain figured it out thanks.
24th May 2021, 11:25 PM
Zach Z
+ 1
#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[0]**2)+(diff[1]**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)
19th Aug 2021, 3:27 PM
Subhransu Sekhar Mohanty
Subhransu Sekhar Mohanty - avatar
0
John Robotane thanks a lot for the suggestion ^_^ Let me try
3rd Mar 2021, 3:08 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
John Robotane it worked. Thanks <3
3rd Mar 2021, 3:13 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
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.
20th May 2021, 6:27 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
Hey Mir Abir Hossain nvm i saw the issie but its still not solving #3?
21st May 2021, 2:27 PM
Zach Z
0
Zach Z can you show me your code?
22nd May 2021, 6:22 AM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
Zach Z welcome
25th May 2021, 9:36 AM
Mir Abir Hossain
Mir Abir Hossain - avatar
0
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.
19th Jun 2021, 12:52 AM
Khalid Bartaouch
Khalid Bartaouch - avatar
19th Mar 2021, 3:05 PM
Mir Abir Hossain
Mir Abir Hossain - avatar