Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Answer of numpy sum of columns is incorrect #8

Open
th4tkh13m opened this issue Sep 1, 2021 · 2 comments
Open

Answer of numpy sum of columns is incorrect #8

th4tkh13m opened this issue Sep 1, 2021 · 2 comments

Comments

@th4tkh13m
Copy link

According to NumPy's glossary, the row axis is 0, and the column axis is 1. Therefore, the answer of
Given the X NumPy matrix, show the sum of its columns should be
X.sum(axis=1) not X.sum(axis=0)
One can try to add the columns to check, the answer is the result of X.sum(axis=1)
Although the answer for the next problem is correct (it does compute the mean values of the elements of X's row), the given comment is still incorrect (# remember: axis=0 columns; axis=1 rows)

@Alekhyadaspet
Copy link

image

Answer is marked incorrect in https://www.freecodecamp.org/learn/data-analysis-with-python/data-analysis-with-python-course/numpy-operations

@Keriafe-Richard
Copy link

its actually axis = 1 for column, and axis = 0 for row
`X = np.array([
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
])

X.sum(axis=0)`

when you run the code it will actually ##sum the column inside of rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants