numpy.lookfor() method-Python
Last Updated :
18 Aug, 2025
numpy.lookfor() function searches through NumPy's documentation for a given keyword or phrase and returns a list of matching functions, classes or terms along with short descriptions.
Example:
Python
import numpy as np
np.lookfor('inverse matrix')
Output:
Search results for 'inverse matrix'
---------------------------------
numpy.linalg.inv
Compute the (multiplicative) inverse of a matrix.
numpy.matrix.I
Return the (multiplicative) inverse of self.
Explanation: Searching "inverse matrix" in NumPy shows numpy.linalg.inv and numpy.matrix.I as options for computing matrix inverses.
Syntax
numpy.lookfor(keyword, module=None, import_modules=True, regenerate=False)
Parameters:
- keyword (str) : The word or phrase to search for.
- module (module, optional) : Restrict search to a given module (default: None, searches all available).
- import_modules (bool, optional) : Whether to import submodules before searching. Default is True.
- regenerate (bool, optional) : If True, regenerates the cache of documentation entries.
Returns: A list of strings with the names of functions/classes/terms that match the search, along with short documentation snippets.
Why Use numpy.lookfor()?
- Helps discover functions without knowing exact names.
- Useful for quick lookups inside the interactive Python shell or Jupyter notebooks.
- Saves time while exploring NumPy’s vast functionality.
- Great for learning and debugging when searching for related utilities.
Examples
Example 1: Searching for "isin"
Python
import numpy as np
print(np.lookfor("isin"))
Output
Search results for 'isin'
----------------------------------
numpy.isinf
Test element-wise for positive or negative infinity.
numpy.compat.is_pathlib_path
Check whether obj is a pathlib.Path object.
numpy.isin
Calculates `element in test_elements`, broadcasting over `element` only.
Explanation: Searching "isin" shows related functions, with numpy.isin being the most relevant for checking array element membership.
Example 2: Searching for "isdigit"
Python
import numpy as np
print(np.lookfor("isdigit"))
Output
Search results for 'isdigit'
----------------------------------
numpy.bytes0.isdigit
B.isdigit() -> bool
numpy.str0.isdigit
S.isdigit() -> bool
numpy.char.isdigit
Returns True for each element if all characters in the string are digits.
numpy.chararray.isdigit
Returns True for each element if all characters in the string are digits.
Explanation: Searching "isdigit" highlights functions like numpy.char.isdigit and numpy.chararray.isdigit, which check if string array elements are digits.
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice