我有一个带有电压和电流值的多索引数据帧:
数据帧:
a b 'name' unit
0 1 2 3 ...
1 1 absd A 0 1.1 3.6 7.6
V 6 66 103 202
2 quat A 1 2.5 14.9 nan
V 0 3 66 nan
我想转换数据帧,以便为每个键获得一个布尔值:
对于任意给定的电压和电流,比如60V和10A,我检查数据帧中最近的电压值,然后检查相应的电流是否大于或小于给定的值。 例如,最后应该是这样的:
a b 'name'
1 1 absd 0
2 quat 1
有了一些for循环,我就可以运行了,但是有没有一个好的、有效的方法来使用pandas,避免for循环和其他迭代方法呢?你知道吗
可以使用^{} 分别选择数据帧的V和A,然后创建布尔掩码,查看A的值是否大于10,V的值是否最接近60。你知道吗
我的方法是
groupby
和idxmin
:退货:
相关问题 更多 >
编程相关推荐