+ 1

Data science-Average of Rows

So when I try to run my code, I get an extra spacing in my numpy array, I've been looking on online forums of python and on Sololearn Q&A but still haven´t managed to find an answer: I would be really greatfull if someone helps me out :) This is the proyect: 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] so for example with this input: 3 2 1 2 1 0.5 1 0.3 the expected output is: [1.5 0.75 0.65] And my output is [1.5 0.75 0.65] I don't have any clue where this extra spacing is coming from :( My code is the following: import numpy as np lista = [] n, p = [int(x) for x in input().split()] for i in range(n): lista.append(input().split()) array = np.array(lista).astype(float).mean(axis=1).round(2) print(array)

6th Aug 2022, 2:19 PM
Pedro Andres Modinger Hathaway
Pedro Andres Modinger Hathaway - avatar
5 Réponses
+ 1
Pedro Andres Modinger Hathaway Bug fixed. You can try now...
9th Aug 2022, 1:58 PM
Jayakrishna 🇮🇳
+ 1
Thanks JayakrishnaIn! Now I got it right!
9th Aug 2022, 2:01 PM
Pedro Andres Modinger Hathaway
Pedro Andres Modinger Hathaway - avatar
0
This particular exersize has a bug in the test.. SL dev team aware of it and working on it. Hope it resolved soon.. You can send report to SL team by : info@sololearn.com
6th Aug 2022, 2:29 PM
Jayakrishna 🇮🇳
0
Thanks! I was getting frustrated as I was stucked for 2 weeks in this excercise.
6th Aug 2022, 2:59 PM
Pedro Andres Modinger Hathaway
Pedro Andres Modinger Hathaway - avatar