# What is the use of scipy.interpolate.interp1d class of SciPy python library?

The scipy.interpolate.interp1d(x, y, kind, axis, copy, bounds_error, fill_value, assumesorted) class of SciPy library, as name implies, is used to interpolate a 1-Dimensional function. Here, x and y are the arrays of values which are used to approximate some function, say f; y=f(x). The output of this class is a function whose call method uses interpolation to find the value of new points.

Below is given the detailed explanation of its parameters −

## Parameters

• x − (N,) array_like

It is a 1-dimensional array of real values.

• y − (…,N,…) array_like

It is a N-dimensional array of real values. The condition is that the length of y along with the interpolation axis should be equal to the length of x.

• kind − str or int, optional

As name implies, this parameter specifies the kind of interpolation. It can of string or integer. If you are going to provide string, then it must be one of the following −

• linear

• nearest

• nearest-up

• zero

• slinear

• cubic

• previous

• next

The default value of this parameter is ‘linear’.

• axis − int, optional

As name implies, this parameter specifies the axis of y along which we need to interpolate.

• copy − bool, optional

This parameter, if true, is used to make the internal copies of x and y. On the other hand, if the value of this parameter is false, the references of x and y are used. The default value of this parameter is ‘True’.

• bounds_error − bool, optional

This parameter, if true, is used to raise a ValueError on attempting interpolation on a value outside the range of x. and y. On the other hand, if the value of this parameter is false, out of bounds values are assigned fill_value. By default, this parameter will raise an error unless fill_value = “extrapolate”.

• fill_value − array-like or (array-like, array_like) or “extrapolate”, optional

There are following three cases for fill_value parameter−

• ndarray or float− If this would be a ndarry or float then the value will be used to fill in for requested points outside of the range of data. The default value is NaN.

• Two-element tuple− If this would be a two-element tuple, both elements will be used in different ways. The first element will be used as a fill value for x_new < x[0]. The second element will be used for x_new > x[-1].

• Extrapolate− If we provide ‘extrapolate’, the points outside the range of data will be generalized or extrapolated.

• assume_sorted − bool, optional

If the value of this parameter is true, the values of x should be an array of monotonically increasing values. On the other hand, if the value of this parameter is false, the values of x can be in any order and the values will be sorted first as well.