NumPy who() Method | Print Arrays in Dictionary
Last Updated :
05 Feb, 2024
The who() function of the NumPy library prints the NumPy ndarray in the given dictionary of the current module.
If no dictionary is passed in or vardict is None then it prints NumPy arrays in the globals() dictionary.
Example
Python3
import numpy as np
gfg = { 'arr_1' : np.arange( 3 ), 'arr_2' : np.arange( 6 ),
'name' : 'some text' , 'number' : 34523 }
np.who(gfg)
|
Output:
Syntax
Syntax: numpy.who(vardict=None)
Parameters
- vardict: A dictionary possibly containing ndarrays. Default is globals().
Returns
Note: It prints out the name, shape, bytes, and type of all of the ndarrays present in Vardict but returns none.
How to Print ndarrays from Python Dictionary?
You can print NumPy arrays from a Python dictionary containing ndarrays using who method of NumPy library.
Let us understand it better with an example:
Example: Print the NumPy arrays in the given Dictionary
In this example, no argument is passed to the numpy.who() function so it prints ndarray in globals() dictionary.
Python3
x = np.arange( 20 )
y = np.ones( 5 )
z = np.zeros( 10 )
np.who()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...