我想为我的数据做一个计算器。
基本上,我在不同的.csv文件中有多个度量,它们被命名为物理表示(temperature_1、current_1、voltage_1 ecc)。我试图在python中制作一个计算器,它给出了一个特定的表达式,例如(current_1 * voltage_1) + (current_2 * voltage_2)能够从每个文件加载数据,并对数据文件上的表达式的结果进行评估。
为了求和、减法、乘和和除法,我已经做了一些简单的函数,但是我仍然无法处理复杂的表达式,例如(current_1 * voltage_1) + (current_2 * voltage_2) + (current_3 * voltage_3) ecc。
我尝试使用解析器,但仍然没有得到结果。
有人知道怎么处理这事吗?
注意:所有.csv都有2列,时间和度量,行数相同,获取时间相同。
发布于 2022-03-04 12:01:33
我已经解决了这个问题。对于任何需要类似功能的人,我在这里分步骤报告解决方案。
从方程中提取变量( parser.parse(equation).variables()) =
- load the data in a dataframe
- insert the column of the measurement in general dataframe
- change the name of that column to the name of your file (e.g. current\_1)通过这样做,您将获得一个列为: time、measurement_1、measurement_2 ecc的数据。
的列计算初始表达式。
希望这能帮到别人
https://stackoverflow.com/questions/71350849
复制相似问题