A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/machine-learning/numpy-ndarray-ndim-method-python/ below:

numpy.ndarray.ndim() method | Python - GeeksforGeeks

numpy.ndarray.ndim() method | Python

Last Updated : 26 Mar, 2020

numpy.ndarray.ndim()

function return the number of dimensions of an array.

Syntax : numpy.ndarray.ndim(arr) Parameters : arr : [array_like] Input array. If it is not already an ndarray, a conversion is attempted. Return : [int] Return the number of dimensions in arr.
Code #1 : Python3
# Python program explaining
# numpy.ndarray.ndim() function

# importing numpy as geek 
import numpy as geek

arr = geek.array([1, 2, 3, 4])

gfg = arr.ndim

print (gfg)
Output :
1
  Code #2 : Python3
# Python program explaining
# numpy.ndarray.ndim() function

# importing numpy as geek 
import numpy as geek

arr = [[1, 2, 3], [4, 5, 6]]

gfg = geek.ndim(arr)

print (gfg)
Output :
2


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4