Reputation: 2062
I have two sets of data (dataframes), each with two columns which relate to eachother (lets call them x and y), like such:
set 1:
x | y
0.1 | 1
0.2 | 2
0.3 | 3
0.4 | 2
0.5 | 3
0.6 | 4
0.7 | 5
set 2:
x | y
0.12 | 0
0.21 | 2
0.31 | 5
0.44 | 4
0.52 | 3
0.61 | 1
0.76 | 1
I want to sum the y values of both sets (at equal x points), however x is slightly misaligned. To solve this I thought it would be best to interpolate both sets from x = 0.12 to 0.7 in 0.001 steps, essentially:
mini = max(set1.x.min(), set2.x.min())
maxi = max(set1.x.max(), set2.x.max())
x_interpolation_points = np.arange(maxi, mini, 0.001)
# Next step: interpolate both sets
# last step: sumY = set1.y + set2.y
How would one accomplisch this? In case of a timeserie I would use resample().interpolate(), but this is not a timeserie..
Upvotes: 0
Views: 1790