I don't understand when it is sum operation or just connect two arrays
x = np.arange(10)
x
#array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
x[4]=44
x
#array([ 0, 1, 2, 3, 44, 5, 6, 7, 8, 9])
xs=np.split(x,5)
xs
#[array([0, 1]), array([2, 3]), array([44, 5]), array([6, 7]), array([8, 9])]
what is this shape ?
xs=np.split(x,5)
xs
#[array([0, 1]), array([2, 3]), array([44, 5]), array([6, 7]), array([8, 9])]
i=2
xscn = np.concatenate((xs[:i]+xs[i+1:]))
xscn
#array([0, 1, 2, 3, 6, 7, 8, 9])
"so why it no summing the array just put them side side (not ariane grande ha ha ha"
f=(xs[:i]+xs[i+1:])
f
#[array([0, 1]), array([2, 3]), array([6, 7]), array([8, 9])]
so it just put one array after other.
cc=np.concatenate(f)
cc
#array([0, 1, 2, 3, 6, 7, 8, 9])
ff=xs[:i]+xs[i+1:]
ff
#[array([0, 1]), array([2, 3]), array([6, 7]), array([8, 9])]
so when it adds and when it just sets one list after other also I can't type the shapes.
type(np.split(x, 5)) == list
, and list
s don't have a shape
, but you can find their len
gths; xs
is a list
, so adding two lists concatenates them:
xs[:i]+xs[i+1:] == [array([0, 1]), array([2, 3]), array([6, 7]), array([8, 9])]
Then you concatenate
all of these tiny arrays into one, which gives you back your original array.
The problem is, Python list
s are not NumPy ndarray
s, and behave differently.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.