title: Pandas eval() nested custom function has different behaviour with arithmetic operators and pandas wrappers
body: <h2>Intro:</h2>
  <p>I've tried to use a &quot;nested&quot; custom function with <code>pandas.eval()</code> but I get a some <code>AttributeError</code> with arithmetic operators, see question at the end.</p>
  <p>I get the same result with <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.mul.html#pandas.DataFrame.mul" rel="nofollow noreferrer"><code>Dataframe.mul()</code></a> and with <code>*</code>, where both results are of type <code>pandas.core.series.Series</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  
  
  _test = pd.DataFrame({'col1': [1, 2]})
  
  _result_1 = _test[&quot;col1&quot;] * 2  # type(_result_1) = &lt;class 'pandas.core.series.Series'&gt;
  
  _result_2 = _test[&quot;col1&quot;].mul(2)  # type(_result_2) = &lt;class 'pandas.core.series.Series'&gt;
  </code></pre>
  <p>I can use the arithmetic operator:</p>
  <pre class="lang-py prettyprint-override"><code>_test[&quot;new_col_1&quot;] = _test.eval(&quot;col1 * 2&quot;)
  </code></pre>
  <p>The use of the custom function is possible:</p>
  <pre class="lang-py prettyprint-override"><code>def cumsum_function_test(input_series):
      return input_series.cumsum()
  
  _test[&quot;new_col_4&quot;] = _test.eval(&quot;@cumsum_function_test(col1)&quot;)
  </code></pre>
  <p>The usage of pandas wrapper operators (e.g. <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.mul.html#pandas.DataFrame.mul" rel="nofollow noreferrer"><code>Dataframe.mul()</code></a>) inline or with a custom function is possible:</p>
  <pre class="lang-py prettyprint-override"><code>def cumsum_function_test(input_series):
      return input_series.cumsum()
  
  _test[&quot;new_col_2&quot;] = _test.eval(&quot;col1.mul(2).cumsum()&quot;)
  
  _test[&quot;new_col_5&quot;] = _test.eval(&quot;@cumsum_function_test(col1.mul(2))&quot;)
  </code></pre>
  <h2>Question:</h2>
  <p>But I get an <code>AttributeError</code> in this case:</p>
  <pre class="lang-py prettyprint-override"><code>_test[&quot;new_col_6&quot;] = _test.eval(&quot;@cumsum_function_test(col1 * 2)&quot;) # =&gt; AttributeError: 'BinOp' object has no attribute 'value'
  </code></pre>
  <p>How can I handle the equation <code>col1 * 2</code> in order to use it in the custom function?</p>
  <p>result:</p>
  <p><a href="https://i.stack.imgur.com/i7NE8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i7NE8.png" alt="enter image description here" /></a></p>