call to column gives row vector instead of column vector python -
hey im making loop have repeatedly update column vector x estimate adding column x estimate, whenever i'm calling column in x estimate givers me row vector , cannot redefine output row column using vstack because no longer able plug in @ start of loop needed new calculations
below output xestimate
xest = [[ 0. 0. ] [ 1. 1. ] [ 1. 1.0001] [ 1. 1.0001]]
later on call 'xest[:,0]' output >> '[0 1 1 1]'
however need column,
'[[0], [1], [1 [1]]'
i dont understand call [:,0] should column should not? thanks
i understand xest
numpy array.
quick answer: can obtain want np.vstack(xest[:,0])
or, better, xest[:,0][:, np.newaxis]
slightly longer answer: why want that? of time, don't, , rely on broadcasting you. there no such thing "column vector" in numpy, cases can handled normal "row vector". corner cases need distinction, can make view , play strides, [:, np.newaxis]
does.
full justification: imagine have array of 10 dimensions, , want 1 vector. want array [[[[[[[[[[1, 1, 1, 1 ...]]]]]]]]]]
? numpy meant work arbitrary dimensions, , therefore, designed general case.
Comments
Post a Comment