Skip to content
Advertisement

insert column into array using scaler obj (numpy.insert)

JavaScript
JavaScript

why C4 did not take column value and insert it before each item in column 1 i think it should be [[ 1 9 6][ 2 99 7][ 3 999 8]]

also

JavaScript

why the result is equal to

JavaScript

not equal to

JavaScript

while the insert axis along axis 0 will inserted normally

JavaScript

the result:

JavaScript

Advertisement

Answer

after searching we found the answer as below:

the output of scaler index was 1d array

JavaScript

so when using scaler index to insert column along axis 1, the values will be assigned for scaler output (1d array) , then transpose the scaler output values to fit the indexed column.

JavaScript

a[:,1]

JavaScript

so the

JavaScript

after that a[:,1] will be transposed to fit with column

JavaScript

while when using scaler index to insert column along axis 1, the scaler output will fit row index,

JavaScript

a[1,:] of c11

JavaScript

so the

JavaScript

a[1,:] of c12 (the values will be broadcasting) to fit obj

JavaScript

so the

JavaScript

the result:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement