Subsetting a column of a DataFrame gives me the y (dependent) variable in form of a NumPy array.
y = train['Survived']
But printing the .shape of the variable y (y.shape) outputs (891,) (notice it's not (891, 1), a column vector).
I would like to perform matrix multiplication of y with a variable with size (1 x 10) using np.matmul, but it's throwing me this error:
Exception: Dot product shape mismatch, (891,) vs (1, 10)
How can I force the y variable to be a column vector with size (891, 1) instead of just (891, )?
y=train['Survived'].values[:,None]y=train['Survived'].to_numpy().reshape(-1, 1)y = train[['Survived']]will also have that column vector shape. However that is quite a bit slower, since it makes a new dataframe (as opposed to extracting a series/column).