简体   繁体   中英

Intrepolating between two data frames

i have two data frames

a=

x   y
10  10
47  9
58  8
68  7
75  6
80  5

b=

x   y
45  10
55  9
66  8
69  7
79  6
82  5

I want to interpolate between them and generate new data frame with N sampling rate

assume N=3 for this example

output is

x          y
10          10
17.5    10
45          10
47           9
51           9
55           9
68           7
68.5        7
69           7
75          6
77          6
79          6
80          5
81          5
82          5

what funcions of pandas should I use ?? please help !

First, you could use df.sample to generate new datas for x only after pd.merge data. Then you should use df.interpolate ... You've got some example on my gist for interpolation...

dataset = pd.merge(a, b, left_on ='x', right_on='x', how='outer')
dataset = dataset.interpolate(method='slinear')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM