## Introduction

NumPy library is a package which enriches Python with many interesting helping functions. We know that array is not present in Python by default. So it's sometimes complicated to do linear algebra in Python. We will discuss an important function provided by NumPy that helps us do linear algebra.

This article will discuss NumPy reshape in Python. We will start our discussion with a quick intro about NumPy. Afterwards, we will discuss NumPy reshape in python. Here, we will discuss its syntax, parameters and some examples of reshaping. We will also discuss some special cases of NumPy reshape in python, which includes working with unknown dimensions and flattening the array. So without any further ado, let's get started!

## What is NumPy.reshape() function?

The NumPy reshape in Python is a NumPy library function. It is used to change the shape of an array. The number of elements in each dimension determines the shape of an array. For example, an array {[1,2,3,4], [5,6,7,8]} is a 2 dimension array.

We can add or remove dimensions or vary the number of elements in each dimension by reshaping. For example, changing the above 2D array in a 1D array.

### Syntax

The syntax of the NumPy reshape function is as follows.

`numpy.reshape(array a, newshape (x,y,z), order='C')`

### Parameters

The parameters present here are,

**Array a:**It is the array taken as input, which is to be reshaped. It is a required field**.**

**Newshape (x,y,z):**The new shape must be compatible with the old shape. If the value is an integer, the outcome will be a 1-D array of that length. One dimension of a form can be -1. The value is derived from the array's size and remaining dimensions in this scenario. It is a**required**field.

**Order = 'C':**The**index order**reads the array a's items. It then arranges the elements into the reshaped array.

**'C'**indicates that the items will be read/written in**C-like index order**, with the final axis index changing the fastest and the first axis index changing the slowest.

- 'F' indicates that the items will be read and written in
**Fortran-like index order**, with the first index changing the fastest and the last index changing the slowest.

- It's worth noting that the 'C' and 'F' options ignore the underlying array's memory layout and solely pertain to the indexing sequence.

- If Fortran is contiguous in memory, 'A' signifies reading/writing the elements in Fortran-like index order. Otherwise, in C-like order. It is
**optional**, so adding it when you write your program is not compulsory.

### Return Value

The numpy.reshape() function in Python returns a new array with the specified shape, reshaping the original array without changing its data.