1

I have a "database" which loads in dataframe series, only when they are needed. The user has the option to input user defined functions to create new series within the database.

Before I can use pandas.eval() on the string, the dataframe needs to be created from the database. Python needs to extract the subjects from the equation below:

MC= ( RR + RR)/4 + @hypot(FL,RL) + @ceil(@log(FR))

The subjects in this equation is RR, RL, FL and FR

NOTE: I'm aware of the eval hatred

RMRiver
  • 625
  • 1
  • 5
  • 19
  • What is the meaning of `@` here? I don't recognize that as Python syntax, can you point us to some documentation for it? – John Zwinck Aug 04 '20 at 11:38
  • @JohnZwinck To use a local variable/function in pandas.eval, a `@` is required. – RMRiver Aug 04 '20 at 13:19
  • @JohnZwinck there isn't much doc for pandas.eval - but see `Accessing Variables in Local/Global Namespace` in this link - https://stackoverflow.com/questions/53779986/dynamic-expression-evaluation-in-pandas-using-pd-eval – RMRiver Aug 04 '20 at 13:23
  • I guess you need to reuse or copy some of the expression parsing code from Pandas itself, since clearly this is not Python syntax (if it were you could just `import ast` and use that). – John Zwinck Aug 06 '20 at 04:37

0 Answers0