Freecodecamp: Numpy - Accessing and Changing Elements, Rows, Columns

Created on 28 May 2020  路  6Comments  路  Source: freeCodeCamp/freeCodeCamp

Describe your problem and how to reproduce it:
The output does not align with the question, nor does it align with the code. I suspect this is what the output was meant to be:

# Output:
# [[ 1  2  20  4  5 ]
# [ 6  7  20  9 10 ]]

Also, I would suggest the formatting of the code to change. Ie. spacing between numbers and [], and spacing between numbers.

Add a Link to the page with the problem:
https://www.freecodecamp.dev/learn/data-analysis-with-python/numpy/accessing-and-changing-elements-rows-columns

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
image

help wanted learn

Most helpful comment

@scissorsneedfoodtoo , well. What was your intent? I assumed the output was there as an example for what the end result should become. Ie. after performing:

a[:, 2] = 20

Or, was the output just another representation of the output of the np.array?

I suggest it be the expected output of the code the user needs to select, as this helps the user clarify what needs to be done.

All 6 comments

Thanks for catching this @Sky020.

I remember copying the output directly from the repl.it console, but I must have messed up the spacing while adding the hashes. Took another look and this is what the console outputs:

[[ 1  2  3  4  5]
 [ 6  7  8  9 10]]

So perhaps it can be:

# Output:
# [[ 1  2  3  4  5]
#  [ 6  7  8  9 10]]

Or with the spacing at the end like you suggest:

# Output:
# [[ 1  2  3  4  5 ]
#  [ 6  7  8  9 10 ]]

@scissorsneedfoodtoo , well. What was your intent? I assumed the output was there as an example for what the end result should become. Ie. after performing:

a[:, 2] = 20

Or, was the output just another representation of the output of the np.array?

I suggest it be the expected output of the code the user needs to select, as this helps the user clarify what needs to be done.

@Sky020, right, my intent was to show what the expected end result would be after running a[:, 2] = 20. So really the output should be

[[ 1  2 20  4  5]
 [ 6  7 20  9 10]]

not

[[ 1  2  3  4  5]
 [ 6  7 20  9 10]]

like it is now. My mistake. I must have forgotten to change the output when I was writing these questions.

Is someone working on this? Can I work on this?

@niteshseram , I am unsure of anyone working on this. You can go ahead, if you want.

Okay. I will be working on it.

Was this page helpful?
0 / 5 - 0 ratings