• Indexing And Slicing In Numpy Array.

    Indexing And Slicing In Numpy Array.

    Indexing And Slicing In Numpy Array. Table Of Contents: Numpy Indexing Numpy Slicing (1) Numpy Indexing Syntax: array[start:end:steps] Parameters: Start: Starting position of the element End: Ending Position Of The Element Steps: Number Of Steps To Jump While Travelling. Example-1: data = np.array([1, 2, 3]) data array([1, 2, 3]) data[0] 1 Note: It will select the value at index position ‘0’ which is ‘1’. Example-2: data[0:2] array([1, 2]) Note: It will select the value from ‘0’ to (end_index -1)  = (2 – 1)  = 1. Example-3: data[1:] array([2, 3]) Note: Here start index is ‘1’ and we did not mention

    Read More

  • How To Convert A 1D Array Into A 2D Array?

    How To Convert A 1D Array Into A 2D Array?

    How To Convert A 1D Array Into A 2D Array? Table Of Contents: np.newaxis np.expand_dims (1) np.newaxis Using np.newaxis will increase the dimensions of your array by one dimension when used once. This means that a 1D array will become a 2D array, a 2D array will become a 3D array, and so on. You can explicitly convert a 1D array with either a row vector or a column vector using np.newaxis. For example, you can convert a 1D array to a row vector by inserting an axis along the first dimension. Example-1: a = np.array([1, 2, 3, 4, 5, 6]) a array([1, 2, 3, 4, 5, 6]) a.shape (6,) Adding

    Read More