我试图计算如下:
df1(具有字符速度的数据帧)(
char_speed
start_time
结束于
end_time
):
char_speed start_time end_time
0 34 3 15
1 19 15 21
2 9 21 28
...
开始时间
结束时间
与
speed
用户在该时间间隔内收听的):
start_time end_time speed
0 9.23 20.929 1.0
1 1.4 20.26 1.5
2 20.0 27.6 1.25
...
start_time end_time speed total_char
0 9.23 20.929 1.0
1 1.4 20.26 1.5
2 20.0 27.6 1.25
...
df2['total_char'].iloc[0]
会是
((15-9.23)*34) + ((20.929-15)*19)
在9.23~20.929之间,
在15~20.929时,速度为19
和
df2['total_char'].iloc[1]
(3-1.4)*0 + ((15-3)*34) + ((20.26-15)*19)
在1.4~20.26之间,
3~15时,速度为34
我是一个熊猫的新手,最近我被熊猫如何在短而简单的编码中高效迷住了,但我不确定是否有一种方法可以在短而简单的编码中计算出来。现在,我只能想一种不使用Pandas函数的方法:调用
df2
然后搜索
df1
然后计算。
如果您能告诉我一种使用Pandas高效地编写代码的方法,那会很有帮助。或者任何函数的建议也会有帮助!
提前谢谢!:)