numpy.alen() in Python (original) (raw)
Last Updated : 28 Dec, 2018
**numpy.alen()
**function is used to return the length of the first dimension of the input array.
Syntax : numpy.alen(arr)
Parameters :
arr : [array_like] Input array.Return : [int]Length of the first dimension of arr.
Code #1 :
import
numpy as geek
in_arr
=
geek.array([[
2
,
0
,
7
], [
0
,
5
,
9
]])
print
(
"Input array : "
, in_arr)
out_dim
=
geek.alen(in_arr)
print
(
"Length of the first dimension of arr: "
, out_dim)
Output:
Input array : [[2, 0, 7], [0, 5, 9]] Length of the first dimension of arr: 2
Code #2 :
import
numpy as geek
in_arr
=
geek.arange(
9
).reshape(
1
,
3
,
3
)
print
(
"Input array : \n"
, in_arr)
out_dim
=
geek.alen(in_arr)
print
(
"Length of the first dimension of arr: "
, out_dim)
Output:
Input array : [[[0 1 2] [3 4 5] [6 7 8]]] Length of the first dimension of arr: 1
Similar Reads
- numpy.angle() in Python numpy.angle() function is used when we want to compute the angle of the complex argument. A complex number is represented by “ x + yi " where x and y are real number and i= (-1)^1/2. The angle is calculated by the formula tan-1(x/y). Syntax : numpy.angle(z, deg=0) Parameters : z : [array_like] A com 2 min read
- numpy.arange() in Python numpy.arange() function creates an array of evenly spaced values within a given interval. It is similar to Python's built-in range() function but returns a NumPy array instead of a list. Let's understand with a simple example: [GFGTABS] Python import numpy as np #create an array arr= np.arange(5 , 1 2 min read
- numpy.find() in Python numpy.core.defchararray.find(arr, substring, start=0, end=None): Finds the lowest index of the sub-string in the specified range. Parameters: arr : array-like or string to be searched. substring : substring to search for. start, end : [int, optional] Range to search in. Returns : An integer array wi 1 min read
- numpy.exp2() in Python numpy.exp2(array, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : This mathematical function helps user to calculate 2**x for all x being the array elements. Parameters : array : [array_like]Input array or object whose elements, we need to test. out : [ndarray, optional 2 min read
- numpy.fabs() in Python numpy.fabs() function is used to compute the absolute values element-wise. This function returns the absolute values (positive magnitude) of the data in arr. It always return absolute values in floats. Syntax : numpy.fabs(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, u 2 min read
- numpy.arctan2() in Python The numpy.arctan2() method computes element-wise arc tangent of arr1/arr2 choosing the quadrant correctly. The quadrant is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1, 0), and the ray ending at the origin and pas 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.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 Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read
- numpy.atleast_1d() in Python numpy.atleast_1d()function is used when we want to Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.atleast_1d(*arrays) Parameters : arrays1, arrays2, ... : [array_like] One or mo 2 min read