### NumPy for Data Science – Part 2

• • 0

## Create NumPy Arrays with Random Numbers

• rand() – the function is used to generate value between 0 to 1.
• randn() – the function is used to generate value close to zero. This may return positive or negative numbers as well.
• ranf() – the function for doing random sampling in NumPy. It returns an Array of specified shape and fills it with random floats inn the half-open interval.
• randint() – the function is used to generate a random number between given range.

## Data Types in NumPy Arrays

Shape and Reshaping In NumPy Arrays

## Shape of an Array

The shape of an array is the number of elements in each dimension.

## Get the Shape of an Array

NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements.

## Reshaping arrays

Reshaping means changing the shape of an array.

The shape of an array is the number of elements in each dimension.

By reshaping we can add or remove dimensions or change number of elements in each dimension.