6

1D Interpolation

Unsolved
Data Wrangling

Difficulty: 2 | Problem written by Mr. Umair
Missing datapoints within a dataset can be approximated by using interpolation. The Interp1D function in scipy.interpolate is used with one variable in a data distribution.

Our data consist of (x,y) coordinates of a car over time. We expect these datapoints to be smooth rather than jagged because the car's motion is restricted. For the given xAxis and yAxis values, interpolate elements in the array "Arr" given below using Scipy.interpolate

Input:

xAxis (time) =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

yAxis (car speed) =  [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

Arr (Interpolation Points) = [2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9]

Output:

result= [5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8]

Sample Input:
<class 'list'>
xAxis: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
<class 'list'>
yAxis: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
<class 'list'>
values: [2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9]

Expected Output:
<class 'list'>
[5.2, 5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Tempore molestiae iusto. Temporibus atque praesentium laborum nisi pariatur, recusandae tempore nulla?

Id consectetur corporis aliquam ipsa vero, expedita porro recusandae mollitia cumque sit qui soluta at, ipsam itaque labore alias cupiditate perspiciatis porro aperiam laboriosam dolor dolorum dicta?

Tempore in quasi, hic laboriosam voluptate maiores, sunt aliquid minima dolorem soluta aspernatur eaque totam, nam officiis voluptatum consectetur voluptatem inventore porro explicabo perspiciatis quam, illum alias et quam? Reprehenderit pariatur dolorum minima dolor sint distinctio id inventore laudantium odio. Eveniet quisquam voluptatem sed aliquid quam fugit nostrum rem error, provident quas magnam at dolores vitae obcaecati possimus reiciendis, natus obcaecati qui quae libero quam cum minima recusandae aliquam, possimus eum cumque?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)