numpy.interp() function - Python Last Updated : 24 Sep, 2024 Comments Improve Suggest changes Like Article Like Report numpy.interp() function returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x. Syntax : numpy.interp(x, xp, fp, left = None, right = None, period = None) Parameters : x : [array_like] The x-coordinates at which to evaluate the interpolated values. xp: [1-D sequence of floats] The x-coordinates of the data points, must be increasing if the argument period is not specified. Otherwise, xp is internally sorted after normalizing the periodic boundaries with xp = xp % period. fp : [1-D sequence of float or complex] The y-coordinates of the data points, same length as xp. left : [optional float or complex corresponding to fp] Value to return for x < xp[0], default is fp[0]. right : [optional float or complex corresponding to fp] Value to return for x > xp[-1], default is fp[-1]. period : [None or float, optional] A period for the x-coordinates. This parameter allows the proper interpolation of angular x-coordinates. Parameters left and right are ignored if the period is specified. Return : [float or complex or ndarray] The interpolated values, same shape as x. Code #1 : Python # Python program explaining # numpy.interp() function # importing numpy as geek import numpy as geek x = 3.6 xp = [2, 4, 6] fp = [1, 3, 5] gfg = geek.interp(x, xp, fp) print (gfg) Output : 2.6Code #2 : Python # Python program explaining # numpy.interp() function # importing numpy as geek import numpy as geek x = [0, 1, 2.5, 2.72, 3.14] xp = [2, 4, 6] fp = [1, 3, 5] gfg = geek.interp(x, xp, fp) print (gfg) Output : [1. 1. 1.5 1.72 2.14] Comment More infoAdvertise with us Next Article numpy.interp() function - Python S sanjoy_62 Follow Improve Article Tags : Python Python-numpy Python numpy-ndarray Practice Tags : python Similar Reads numpy.i0() function | Python numpy.i0() function is the modified Bessel function of the first kind, order 0. it's usually denoted by I0. Syntax : numpy.i0(x) Parameters : x : [array_like, dtype float or complex] Argument of the Bessel function. Return : [ndarray, shape = x.shape, dtype = x.dtype] The modified Bessel function ev 1 min read numpy.iinfo() function â Python numpy.iinfo() function shows machine limits for integer types. Syntax : numpy.iinfo(dtype) Parameters : dtype : [integer type, dtype, or instance] The kind of integer data type to get information about. Return : Machine limits for integer types. Code #1 : Python3 # Python program explaining # numpy. 1 min read numpy.imag() function - Python numpy.imag() function return the imaginary part of the complex argument. Syntax : numpy.imag(arr) Parameters : arr : [array_like] Input array. Return : [ndarray or scalar] The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elem 1 min read numpy.intersect1d() function in Python numpy.intersect1d() function find the intersection of two arrays and return the sorted, unique values that are in both of the input arrays. Syntax: numpy.intersect1d(arr1, arr2, assume_unique = False, return_indices = False) Parameters : arr1, arr2 : [array_like] Input arrays. assume_unique : [bool] 2 min read numpy.in1d() function in Python numpy.in1d() function test whether each element of a 1-D array is also present in a second array and return a boolean array the same length as arr1 that is True where an element of arr1 is in arr2 and False otherwise. Syntax : numpy.in1d(arr1, arr2, assume_unique = False, invert = False) Parameters 2 min read Like