interpolation

How to do a linear interpolation in pandas taking values of X into account?

How to do a linear interpolation in pandas taking values of X into account? Question: I have a data-frame with two columns: X and Y. Some of the values in Y are missing (np.nan). I would like to fill the NaNs using a linear interpolation. In more details, I want to order the data frame …

Total answers: 2

Interpolation of a pandas DataFrame

Interpolation of a pandas DataFrame Question: I do have a pandas DataFrame (size = 34,19) which I want to use as a lookup table. But the values I want to look up are "between" the values in the dataframe For example: 0.1 0.2 0.3 0.4 0.5 0.1 4.01 31.86 68.01 103.93 139.2 0.2 24.07 57.49 …

Total answers: 2

4D interpolation for irregular (x,y,z) grids by python

4D interpolation for irregular (x,y,z) grids by python Question: I have some data that comes in the form (x, y, z, V) where x,y,z are distances, and V is the moisture. I read a lot on StackOverflow about interpolation by python like this and this valuable posts, but all of them were about regular grids …

Total answers: 1

Fastest way to get all the points between two (X,Y) coordinates in python

Fastest way to get all the points between two (X,Y) coordinates in python Question: So I have a shapely LineString: print np.round(shapely_intersecting_lines.coords).astype(np.int) >>> array([[ 1520, -1140], [ 1412, -973]]) This can be interpreted as a numpy array as well as seen above. I want to get all the points in between, that is I want …

Total answers: 5

`ValueError: A value in x_new is above the interpolation range.` – what other reasons than not ascending values?

`ValueError: A value in x_new is above the interpolation range.` – what other reasons than not ascending values? Question: I receive this error in scipy interp1d function. Normally, this error would be generated if the x was not monotonically increasing. import scipy.interpolate as spi def refine(coarsex,coarsey,step): finex = np.arange(min(coarsex),max(coarsex)+step,step) intfunc = spi.interp1d(coarsex, coarsey,axis=0) finey = …

Total answers: 2

OpenCV resize() result is wrong?

OpenCV resize() result is wrong? Question: Sample program that upscales 2×2 matrix to 5×5 using bilinear interpolation. Result that OpenCV produces has artifacts at the borders for such simple case. gy, gx = np.mgrid[0:2, 0:2] gx = np.float32(gx) print(gx) res = cv2.resize(gx,(5,5), fx=0, fy=0, interpolation=cv2.INTER_LINEAR) print(res) Output: [[ 0. 1.] [ 0. 1.]] [[ 0. …

Total answers: 3

How to implement element-wise 1D interpolation in Tensorflow?

How to implement element-wise 1D interpolation in Tensorflow? Question: I would like to apply 1D interploation to each element of a tensor in Tensorflow. For example, if it is a matrix, we can use interp1d. from scipy.interpolate import interp1d q = np.array([[2, 3], [5, 6]]) # query x = [1, 3, 5, 7, 9] # …

Total answers: 2

linear interpolation between two data points

linear interpolation between two data points Question: I have two data points x and y: x = 5 (value corresponding to 95%) y = 17 (value corresponding to 102.5%) No I would like to calculate the value for xi which should correspond to 100%. x = 5 (value corresponding to 95%) xi = ?? (value …

Total answers: 3

How can I perform two-dimensional interpolation using scipy?

How can I perform two-dimensional interpolation using scipy? Question: This Q&A is intended as a canonical(-ish) concerning two-dimensional (and multi-dimensional) interpolation using scipy. There are often questions concerning the basic syntax of various multidimensional interpolation methods, I hope to set these straight too. I have a set of scattered two-dimensional data points, and I would …

Total answers: 1