Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy squeeze function Example

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function

import numpy as np

in_arr = np.array([[[1, 2, 3], [4, 5, 6]]])

print ("Input array : 
", in_arr)
print("Shape of input array : ", in_arr.shape)

out_arr = np.squeeze(in_arr)

print ("output squeezed array : 
", out_arr)
print("Shape of output array : ", out_arr.shape)
Comment

.squeeze function in numpy

The squeeze() function is used to remove single-dimensional entries from the
shape of an array.
Comment

Python NumPy squeeze function Syntax

numpy.squeeze(arr, axis=None )
Comment

Python NumPy squeeze function Example with axis

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function
import numpy as geek
in_arr = geek.arange(9).reshape(1, 3, 3)

print ("Input array : 
", in_arr)
out_arr = geek.squeeze(in_arr, axis = 0)

print ("output array : 
", out_arr)
print("The shapes of Input and Output array : ",in_arr.shape, out_arr.shape)
Comment

Python NumPy squeeze function Example with axis=1

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function
import numpy as geek
in_arr = geek.arange(9).reshape(1, 3, 3)

print ("Input array : 
", in_arr)
out_arr = geek.squeeze(in_arr, axis = 1)

print ("output array : 
", out_arr)
print("The shapes of Input and Output array : ",in_arr.shape, out_arr.shape)
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy delete Function Example Deletion from 1D array 
Python :: selenium wait until 
Python :: cbind arrays python 
Python :: fibonacci sequence 
Python :: python print every row of dataframe 
Python :: pytest monkeypatch 
Python :: how to run python on ios 
Python :: private key 
Python :: how to access pandas column 
Python :: pairs with specific difference 
Python :: Python NumPy ndarray flat function Syntax 
Python :: merge sort function 
Python :: length of queue python 
Python :: string representation of date time 
Python :: start virtualenv with python version 
Python :: or operator in python 
Python :: Maximum sum subarray of size ‘K’ 
Python :: fastest way to iterate dictionary python 
Python :: concatenate strings and int python 
Python :: path in python 
Python :: dfs algorithm python 
Python :: convert time 
Python :: python list pop equivalent 
Python :: python read array line by line 
Python :: python decimal 
Python :: django form date picker 
Python :: how to use variable from another function in python 
Python :: python function __name__ 
Python :: django.core.exceptions.ImproperlyConfigured: Field name is not valid for model 
Python :: python find in string 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =