Posts

Showing posts with the label arrays

2D Numpy Arrays

Image
2D Numpy Arrays Lets recreate the numpy arrays. If you ask for the type of these arrays,Python tells you that they are numpy.ndarray. `numpy`. tells you its a type that was defined in the numpy package. `ndarray` stands for n-dimensional array. The arrays `np_height` and `np_weight` are one-dimensional arrays, but its perfectly possible to create 2 dimensional, three dimensional, heck even seven dimensional arrays! You can create a 2D numpy array from a regular Python list of lists. Lets try to create one numpy array for all height and weight data of your family, like this: If you print out `np_2d` now, youll see that it is a rectangular data structure: Each sublist in the list, corresponds to a row in the two dimensional numpy array. From `np_2d.shape`, you can see that we indeed have 2 rows and 5 columns. `shape` is a so-called attribute of the `np2d` array, that can give you more information about what the data structure looks like. In [ 1 ] : import numpy as np In [ 2 ] : np_...