I have a issue with sympy, I have a data frame columns which has to be calculated with a formula and the formula is in string format I am using sympy it's taking only one value but not the series value my code
import sympy
def eval_eqn(eqn,in_dict):
sub = {sympy.symbols(key):item for key,item in in_dict.items()}
ans = sympy.simplify(eqn).evalf(subs = sub)
return ans
in_dict = {"x": df['bike_count'],"y":df['car_count'],"z":df['flight_count']}
eqn = "x+y+z"
eval_eqn(eqn,in_dict)
when I use this getting an error says that series has to attribute func
.any suggestions?
I did some minor changes to your code. Below is the updated version. Kindly change it as per your needs.
Edited for the comment on more than one value in df
Please see it and let me know if you need more help. :)