简体   繁体   English

在两个数据帧之间进行内插

[英]Intrepolating between two data frames

i have two data frames 我有两个数据帧

a= A =

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

b= 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 我想在它们之间进行插值并生成具有N个采样率的新数据帧

assume N=3 for this example 假设此示例N = 3

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. 首先,您可以使用df.sample仅在pd.merge数据之后为x生成新数据。 Then you should use df.interpolate ... You've got some example on my gist for interpolation... 那么你应该使用df.interpolate ...你已经有了一些例如在我的要点进行插值...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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