pandas 计算列比大于0.05且列差介于15和30之间的次数

t40tm48m  于 2023-03-06  发布在  其他
关注(0)|答案(1)|浏览(92)
Datetime              ratio                  dif
2022-06-09 12:33:00  -0.3861241598107547    -299.50183804712964
2022-06-09 12:34:00 -0.360130489922861  -274.88184087028105
2022-06-09 12:35:00 -0.22108950904852795    -166.02672464097395
2022-06-09 12:36:00 -0.18316426991752388    -135.2928226604197
2022-06-09 12:37:00 -0.09932437001820388    -72.14644129886278
2022-06-09 12:38:00 -0.0820362738010348 -58.58522049972339
2022-06-09 12:39:00 -0.04310125282586597    -30.25449340858836
2022-06-09 12:40:00 -0.48650055935157194    -335.5773828284086
2022-06-09 12:41:00 -0.040251923613339506   -27.620467464237436
2022-06-09 12:42:00 -0.19392674180880734    -132.750611837801
2022-10-10 23:59:59         0                             0

我怎样才能知道有多少次ratio大于0.05,同时dif在15-30之间?这个 Dataframe 叫做帧

zwghvu4y

zwghvu4y1#

ratio_condition = df['ratio'].abs() > 0.05
dif_condition = (df['dif'].abs() >= 15) & (df['dif'].abs() <= 30)

count = (ratio_condition & dif_condition).sum()

相关问题