Sunday, December 29, 2024
Google search engine
HomeLanguagesnumpy.unravel_index() function | Python

numpy.unravel_index() function | Python

numpy.unravel_index() function converts a flat index or array of flat indices into a tuple of coordinate arrays.

Syntax : numpy.unravel_index(indices, shape, order = ā€˜Cā€™)
Parameters :
indices : [array_like] An integer array whose elements are indices into the flattened version of an array of dimensions shape.
shape : [tuple of ints] The shape of the array to use for unraveling indices.
order : [{ā€˜Cā€™, ā€˜Fā€™}, optional] Determines whether the multi-index should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order.

Return : [tuple of ndarray] Each array in the tuple has the same shape as the indices array.

Code #1 :




# Python program explaining
# numpy.unravel_index() function
Ā Ā 
# importing numpy as geekĀ 
import numpy as geek
Ā Ā 
gfg = geek.unravel_index([22, 41, 37], (7, 6))
Ā Ā 
print(gfg)Ā 


Output :

(array([3, 6, 6]), array([4, 5, 1]))

Ā 
Code #2 :




# Python program explaining
# numpy.unravel_index() function
Ā Ā 
# importing numpy as geekĀ 
import numpy as geek
Ā Ā 
gfg = geek.unravel_index([22, 41, 37], (7, 6), order = 'F')
Ā Ā 
print(gfg)Ā 


Output :

(array([1, 6, 2]), array([3, 5, 5]))
RELATED ARTICLES

Most Popular

Recent Comments

ź°•ģ„œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
źøˆģ²œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
źµ¬ģ›”ė™ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź°•ģ„œźµ¬ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ģ˜¤ģ‚°ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ź“‘ėŖ…ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ģ•ˆģ–‘ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė™ķƒ„ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ģ„œģšøģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶„ė‹¹ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ė¶€ģ²œģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ķ™”ź³”ė™ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź°•ģ„œźµ¬ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ź³ ģ–‘ģ¶œģž„ģ•ˆė§ˆ on How to store XML data into a MySQL database using Python?
ķ™”ģ„±ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?
ģ²œķ˜øė™ģ¶œģž„ė§ˆģ‚¬ģ§€ on How to store XML data into a MySQL database using Python?