I have an array of 5 numbers:
A = [10, 20, 40, 80, 110]
I need to create a new array with a 10nth length numbers.
The extra numbers could be the average number between the two # of A
.
for example: EDIT B = [10 , 15 , 20 ,30, 40, 60, 80, 95, 110 ]
Is it possible using a scipy or numpy function ?
Use numpy.interp:
import numpy as np
Y = [10, 20, 40, 80, 110]
N = len(Y)
X = np.arange(0, 2*N, 2)
X_new = np.arange(2*N-1) # Where you want to interpolate
Y_new = np.interp(X_new, X, Y)
print(Y_new)
yields
[ 10. 15. 20. 30. 40. 60. 80. 95. 110.]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With