NumPy | Python Methods and Functions

** **

** numpy.argwhere() ** is used to find non-zero indices of array elements grouped by element.

Syntax: numpy.argwhere (arr)

Parameters:

arr:[array_like] Input array.

Return:[ndarray] Indices of elements that are non-zero. Indices are grouped by element.

** Code # 1: **

` `

` ` |

` `

` `

** Output:**

Input array: [[2, 0, 7 ], [0, 5, 9]] Output indices of non zero array element: [[0 0] [0 2] [1 1] [1 2]]

** Code # 2: **

` `

` ` ` # Python program explaining `

` Function # argwhere () `

` impo rt `

` numpy as geek `

` # input array `

` in_arr `

` = `

` geek.arange (`

` 8 `

`). reshape (`

` 4 `

`, `

` 2 `

`) `

` print `

` (`

` "Input array:" `

`, in_arr) `

` out_arr `

` = `

` geek.argwhere (in_arr & gt; `

` 4 `

`) `

` ` ` print `

` (`

` "Output indices greater than 4:" `

`, out_arr) `

` `

** Exit:**

Input array: [[0 1] [2 3] [ 4 5] [6 7]] Output indices greater than 4: [[2 1] [3 0] [3 1]]

Pandas 1.x Cookbook: Practical recipes for scientific computing, time series analysis, and exploratory data analysis using Python, 2nd Edition....

05/09/2021

Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems PDF, 2nd Edition. This book assumes you know next to nothing about m...

22/08/2021

The genesis of this book began in 2012. Hadoop was being explored in mainstream organizations, and we believed that information architecture was about to be transformed. For many years, business intel...

10/07/2020

Computer languages have so far been of the ‘interpreted’ or the ‘compiled’ type. Compiled languages (like ‘C’) have been more common. You prepare a program, save it (the debugged version),...

23/09/2020

X
# Submit new EBook