I’m writing a part about numpy while listening to a Python lecture. The reason I need your help is that the numpy function does not output as it appears in the lecture, that is, as intended.
(I’m learning about the functions of Python.)
This is the simple code. (These are all written by Colab.)
import numpy as np
x = np.arange(1, 20, 1)
print(x)
ind = np.where(x<=6) # Satisfying Position Output
print(ind)
The result I expected:
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
(array([0, 1, 2, 3, 4, 5], dtype=int64),)
an output of insanity that appeared out of nowhere:
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
(array([0, 1, 2, 3, 4, 5]),)
Finding the reason for the above anomalous results feels like picking stars in the sky to me.
This is a very short code, but unlike what’s running in the video, dtype… part didn’t come out.
ChatGPT just advises me to fix the code, but it doesn’t give an explanation as to why the result is different.
Also, it’s hard to find any information related to this with Googling at my level. Please help me, everyone!