Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

numpy.who() function in Python

  • Last Updated : 05 Sep, 2020

numpy.who(vardict=None) function prints the Numpy ndarrays in the given dictionary. If there is no dictionary passed in or vardict is None then prints NumPy arrays in the globals() dictionary.


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

vardict: A dictionary possibly containing ndarrays. Default is globals().


out: None

Note: It prints out the name, shape, bytes and type of all of the ndarrays present in vardict but returns none.

Example #1: In this example a dictionary is passed as argument to the numpy.who() function.


# import the numpy module as np
import numpy as np
# dictionary containing numpy ndarrays
gfg = {'arr_1': np.arange(3), 'arr_2': np.arange(6),
       'name': 'some text', 'number': 34523}
# passing the dict as argument


Example #2: In this example no argument is passed to the numpy.who() function so it prints ndarray in globals() dictionary.


# import the numpy module as np
import numpy as np
# creating numpy ndarrays
x = np.arange(20)
y = np.ones(5)
z = np.zeros(10)
# function called without passing any argument


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!