numpy.empty_like() in Python (original) (raw)
Last Updated : 29 Nov, 2018
numpy.empty_like(a, dtype = None, order = ‘K’, subok = True) : Return a new array with the same shape and type as a given array.
Parameters :
shape : Number of rows
order : C_contiguous or F_contiguous
dtype : [optional, float(by Default)] Data type of returned array.
subok : [bool, optional] to make subclass of a or not
Return :
array with the same shape and type as a given array.
import
numpy as geek
a
=
geek.empty_like([
2
,
2
], dtype
=
int
)
print
(
"\nMatrix a : \n"
, a)
c
=
a
=
([
1
,
2
,
3
], [
4
,
5
,
6
])
print
(
"\nMatrix c : \n"
, geek.empty_like(c))
Output :
Matrix a : [ 16843008 1058682594]
Matrix c : [[0 0 0] [0 0 0]]
Note :
These codes won’t run on online-ID. Please run them on your systems to explore the working.
Similar Reads
- numpy.empty() in Python numpy.empty(shape, dtype = float, order = 'C') : Return a new array of given shape and type, with random values. Parameters : -> shape : Number of rows -> order : C_contiguous or F_contiguous -> dtype : [optional, float(by Default)] Data type of returned array. # Python Programming illustra 1 min read
- numpy.full_like() in Python The numpy.full_like() function return a new array with the same shape and type as a given array.Syntax : numpy.full_like(a, fill_value, dtype = None, order = 'K', subok = True) Parameters : shape : Number of rows order : C_contiguous or F_contiguous dtype : [optional, float(by Default )] Data type o 2 min read
- numpy.matlib.empty() function | Python numpy.matlib.empty() function return a new matrix of given shape and type, without initializing entries. Syntax : numpy.matlib.empty(shape, dtype = None, order = 'C') Parameters : shape : [int or tuple of int] Shape of the empty matrix. dtype : [data-type, optional] Desired output data-type. order : 1 min read
- numpy.ones_like() in Python The numpy.one_like() function returns an array of given shape and type as a given array, with ones. Syntax: numpy.ones_like(array, dtype = None, order = 'K', subok = True) Parameters : array : array_like input subok : [optional, boolean]If true, then newly created array will be sub-class of array; o 2 min read
- numpy.zeros_like() in Python This numpy method returns an array of given shape and type as given array, with zeros. Syntax: numpy.zeros_like(array, dtype = None, order = 'K', subok = True) Parameters : array : array_like input subok : [optional, boolean]If true, then newly created array will be sub-class of array; otherwise, a 2 min read
- numpy.index() in Python numpy.core.defchararray.index(arr, substring, start=0, end=None): Finds the lowest index of the sub-string in the specified range But if substring is not found, it raises ValueError. Parameters: arr : array-like or string to be searched. substring : substring to search for. start, end : [int, option 1 min read
- numpy.any() in Python The numpy.any() function tests whether any array elements along the mentioned axis evaluate to True. Syntax : numpy.any(a, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c) Parameters : array :[array_like]Input array or object whose elements, we need to test. axis : [i 3 min read
- numpy.isreal() in Python numpy.isreal(array) : Test element-wise whether it is a real number or not(not infinity or not Not a Number) and return the result as a boolean array. Parameters : array : [array_like] Input array whose element we want to test Return : boolean array containing the result Code 1 : Python Code # Pytho 2 min read
- numpy.isnan() in Python The numpy.isnan() function tests element-wise whether it is NaN or not and returns the result as a boolean array. Syntax : numpy.isnan(array [, out]) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array placed with 2 min read
- numpy.isneginf() in Python The numpy.isneginf() function tests element-wise whether it is negative infinity or not, and returns the result as a boolean array. Syntax : numpy.isneginf(array, y = None) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boolean 2 min read