8. Assignment Using Boolean Arrays Continued-nympy.zeros

Screen Link: https://app.dataquest.io/m/290/boolean-indexing-with-numpy/8/assignment-using-boolean-arrays-continued

My Code: <’

Replace this line with your code

create a new column filled with 0.

zeros = np.zeros([taxi.shape[0], 1])
taxi_modified = np.concatenate([taxi, zeros], axis=1)
What I expected to happen:

numpy.zeros has following definition. numpy. zeros ( shape , dtype=float , order=‘C’ )

Return a new array of given shape and type, filled with zeros.

Parameters: shape : int or tuple of ints

Shape of the new array, e.g., (2, 3) or 2 .

dtype : data-type, optional

The desired data-type for the array, e.g., numpy.int8 . Default is numpy.float64 .

order : {‘C’, ‘F’}, optional, default: ‘C’

Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.
Returns: out : ndarray

Array of zeros with the given shape, dtype, and order.
What actually happened:

I am not sure what second parameter “1” means in below code

zeros = np.zeros([taxi.shape[0], 1])

Which parameter does it represent?

Replace this line with the output/error

1 Like

hey @gulabs_rawat
you may refer to this documentation (you have printed part of it here) for a detailed explanation

1 - take it as the number of columns. taxi.shape[0] - will give number of rows.

hope this helps.