# Issue with columns added to RDataFrame using experimental RReader and Compute within pyROOT

**URL:** <https://root-forum.cern.ch/t/issue-with-columns-added-to-rdataframe-using-experimental-rreader-and-compute-within-pyroot/39022>\
**Category:** ROOT\
**Tags:** python, rdataframe, tmva\
**Created:** [April 21, 2020, 8:31pm UTC](https://root-forum.cern.ch/t/issue-with-columns-added-to-rdataframe-using-experimental-rreader-and-compute-within-pyroot/39022 "2020-04-21T20:31:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan\_m](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/a8b319/32.png) [@dan\_m](https://root-forum.cern.ch/u/dan_m)\
**Post date:** [April 21, 2020, 8:31pm UTC](https://root-forum.cern.ch/t/issue-with-columns-added-to-rdataframe-using-experimental-rreader-and-compute-within-pyroot/39022/1 "2020-04-21T20:31:25Z")

</div>

Dear experts,

I am trying to load an existing TMVA BDT model using pyROOT and compute the BDT scores using columns from a RDataFrame as inputs and add the output as a column. I followed the answer by @swunsch in [RDataFrame and TMVA in pyroot](https://root-forum.cern.ch/t/rdataframe-and-tmva-in-pyroot/38930/3) and managed to add a column using `TMVA::Experimental::RReader` and `TMVA::Experimental::Compute`. However, it appears that it is not possible to use this column in a more complicated expression to make another column.

```auto
gInterpreter.ProcessLine('TMVA::Experimental::RReader model("%s");'%(xmlfile))
nBDTVars = len(ROOT.model.GetVariableNames())
gInterpreter.ProcessLine("computeModel = TMVA::Experimental::Compute<%d, float>(model);"%(nBDTVars))
DF = DF.Define("newbdt", ROOT.computeModel, ROOT.model.GetVariableNames())

```

Now if I do `DF.Histo1D("newbdt")` it works normally.

However, if I perform a simple arithmetic operation, such as `DF.Define("newbdt2","newbdt+1")` I get the following error:

```auto
input_line_169:2:35: error: invalid operands to binary expression ('__rdf1::newbdt5_type' (aka 'vector<float>') and 'int') 
return newbdt+1

note: candidate function not viable: no known conversion from '__rdf1::newbdt5_type' (aka 'vector<float>') to 'TString' for 1st argument
operator+(TString s, T i)

```

followed by several lines of similar errors.

I understand this is an experimental feature and I was wondering if it has been reported already. If so, is there a known workaround, or am I doing something wrong?

Thanks,  
Spandan

_ROOT Version:_ 6.20/01  
_Platform:_ EL7

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [April 21, 2020, 9:02pm UTC](https://root-forum.cern.ch/t/issue-with-columns-added-to-rdataframe-using-experimental-rreader-and-compute-within-pyroot/39022/2 "2020-04-21T21:02:22Z")

</div>

Hi!

The inference returns a `vector<float>` because you could have more than a single output node for the model. So put a `newbdt[0] +1` as expression and you are good to go!

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 5, 2020, 9:02pm UTC](https://root-forum.cern.ch/t/issue-with-columns-added-to-rdataframe-using-experimental-rreader-and-compute-within-pyroot/39022/3 "2020-05-05T21:02:24Z")

</div>

Closed on May 5, 2020, 9:02pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
