Compute Dataframe Columns From A String Formula In Variables?
I use an excel file in which I determine the names of sensor, and a formula allowing me to create a new 'synthetic' sensor based on real sensors. I would like to write the formula
Solution 1:
I think pandas.query is what you want. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html
Example:
formula_cell = "y1 + y2 + y3 + y4"df['value'] = df.query(formula_cell)
Post a Comment for "Compute Dataframe Columns From A String Formula In Variables?"