numpy.asarray_chkfinite() in Python

The numpy.asarray_chkfinite() function converts the input to an array, checking for NaNs or Infs.

Syntax

Parameter

a : This parameter represents an input data, which can be in the form of lists, tuples, lists of tuples, tuples of tuples and ndarrays,etc,.that can be converted to an array.

dtype : It is an optional parameter, and by default, the data-type is inferred from the input data.

order : This parameter decides whether to use row-major (C-style) or column-major (Fortran-style) memory representation and by default, the ‘C-style’ is selected.

Return

This function returns an array interpretation of parameter ‘a’. If ‘a’ is a subclass of ndarray, a base class ndarray is returned.

Raises

This function raises a ValueError if the parameter ‘a’ contains NaN (Not a Number) or Inf (Infinity).

Example 1

Output

Example 2

Output

Example 3 : When value error occurs

Output

Pin It on Pinterest

Share This