我有一个数据帧,需要根据条件进行过滤,如下所示。基本上,根据验证的速度进行过滤,除非它等于0,然后使用速度列
above_limit_speed = (df_cimbined_traff[df_cimbined_traff['Speed'] > df_cimbined_traff[df_cimbined_traff['Verified_speed']) > df_cimbined_traff['Postedspeed']].groupby('deploymentid')['Speed'].count().reset_index().rename(columns={'Speed': 'count_above_speed_limit'}).set_index('deploymentid')
示例数据帧
X_value - Speed - Verified_Speed - Post Speed
bluergh - 50 - 51 - 49
blasdu - 50 - 0 - 30
ausdas - 60-60-40
我已经尝试了上面的方法,以及它的各种变体,但是对于用Pandas在Python中处理这个问题的最佳方法感到非常困惑
所以基本上
我想将post速度与验证速度进行比较,除非该速度等于零,我想将其与速度进行比较
非常感谢您的帮助
谢谢
您可以使用所需的逻辑创建一个新列
prev_speed
相关问题 更多 >
编程相关推荐