+ 1

Data Science Module Average of rows

Hi ! Problem : Data Science - Average of Rows In a matrix, or 2-d array X, the averages (or means) of the elements of rows is called row means. Task Given a 2D array, return the rowmeans. Input Format First line: two integers separated by spaces, the first indicates the rows of matrix X (n) and the second indicates the columns of X (p) Next n lines: values of the row in X Output Format An numpy 1d array of values rounded to the second decimal. 2 2 1.5 1 2 2.9 Sample Output [1.25 2.45] ---------------------------------------------------------------- My code : import numpy as np n, p = [int(x) for x in input().split()] mat=np.empty((n,p)) means=np.empty(n) for i in range(n): inpts=[float(x) for x in input().split()] mean=0 for j in range(p): mean=mean+inpts[j] means[i]=round(mean/p,2) print(means) ------------------------------------------- I have the right values in test case #2 by it is taking it as error Input 3 2 1 2 1 0.5 1 0.3 Your Output [1.5 0.75 0.65] Expected Output [1.5 0.75 0.65] I'm stuck on this project for three days i tested my code on my computer and it i working fine . Any ideas ?

6th Aug 2022, 12:26 AM
jebari jihed
jebari jihed - avatar
6 Answers
+ 3
jebari jihed / Jayakrishna🇮🇳 There is no current update on the bug
6th Aug 2022, 1:03 PM
BroFar
BroFar - avatar
+ 2
jebari jihed It has a bug..Not sure, is it solved or not.. please wait for it fixed.. https://www.sololearn.com/Discuss/3067969/?ref=app edit: BroFar Sir, Can you add status of this bug, if any update info....
6th Aug 2022, 7:41 AM
Jayakrishna 🇮🇳
+ 2
I think there is bug in this Project, automatically adding space after 1st value in output when we use numpy I tried in Code Playground and there is same problem so I assume it's a problem of numpy because when you use list then it gives proper result. https://code.sololearn.com/cJu3mLkn7s0m/?ref=app
6th Aug 2022, 1:24 PM
A͢J
A͢J - avatar
+ 1
here is the link for my code : https://code.sololearn.com/cJjnAFzyGnp1
6th Aug 2022, 12:35 AM
jebari jihed
jebari jihed - avatar
+ 1
jebari jihed the module project 8 data science playground should be fixed.
9th Aug 2022, 1:27 PM
BroFar
BroFar - avatar
0
import numpy as np n, p = [int(x) for x in input().split()] # Initialize matrix matrix = [] #Entry row elements separated by space for i in range(n): matrix.append(input().split()) print(np.array(matrix).astype(np.float16).mean(axis=1).round(2))
25th Mar 2023, 1:31 PM
Froilan Q. Sulit
Froilan Q. Sulit - avatar