- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.squeeze
This function removes one-dimensional entry from the shape of the given array. Two parameters are required for this function.
numpy.squeeze(arr, axis)
Where,
Sr.No. | Parameter & Description |
---|---|
1 | arr Input array |
2 | axis int or tuple of int. selects a subset of single dimensional entries in the shape |
Example
import numpy as np x = np.arange(9).reshape(1,3,3) print 'Array X:' print x print '\n' y = np.squeeze(x) print 'Array Y:' print y print '\n' print 'The shapes of X and Y array:' print x.shape, y.shape
Its output is as follows −
Array X: [[[0 1 2] [3 4 5] [6 7 8]]] Array Y: [[0 1 2] [3 4 5] [6 7 8]] The shapes of X and Y array: (1, 3, 3) (3, 3)
numpy_array_manipulation.htm
Advertisements