Home | News | Documentation | Download

How might a new column be added to a RooDataSet in a vectorised way a bit like the pandas DataFrame apply method?

Hey there. I’m looking to do something like a DataFrame apply to a RooDataSet in order to add a new column.

Vectorised operations can be done on pandas DataFrames in ways like the following:

import pandas as pd

df = pd.DataFrame(columns = ['a', 'b'])
df['a'] = [1, 2, 3]
df['b'] = [1, 2, 3]

df['c'] = df['a'] + df['b']
df['d'] = df.apply(lambda row: row['c']**2, axis=1)

Particularly, the apply method can be used to add a new column in a vectorised sort of way, avoiding looping over rows and so on.

How might a column be added to a RooDataSet in a similar sort of way?

from ROOT import RooArgSet, RooDataSet, RooRealVar

a = RooRealVar('a', 'a', -10, 10)
b = RooRealVar('b', 'b', -10, 10)
varset = RooArgSet(a, b)
ds     = RooDataSet('ds', 'dataset', varset)
for entry in [1, 2, 3]:
    ds.add(RooArgSet(a, b))

for row_index in list(range(0, ds.numEntries())):

Hello @wdbm,

RooFit doesn’t support this, unfortunately. The data interface is on the list of things to be redesigned, but that will take a while.
Single-row filling is currently the only option.

1 Like

Ok, thanks for the information on that.

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