Issues with RDF FromPandas

Hello,
I am trying to write a pyroot code for writing some trees from pandas

import pandas as pd
import uproot
import ROOT

df = pd.DataFrame()
fileMC = uproot.open(“inFile.root”)
signal=fileMC[“b2hh”].arrays([“idBDT”,“bDOCA”],library=“pd”)
signal[“classifyTag”]=1
data = {key: signal[key].values for key in [‘idBDT’, ‘bDOCA’, ‘classifyTag’]}
rdf = ROOT.RDF.FromPandas(data)

rdf.Snapshot(‘treeName’, ‘outFile.root’)

basically I’m trying to replicate
https://root.cern.ch/doc/master/df035__RDFFromPandas_8py.html

but I’m getting this error

AttributeError: <namespace cppyy.gbl.ROOT.RDF at 0x6b575b0> has no attribute ‘FromPandas’. Full details:
type object ‘RDF’ has no attribute ‘FromPandas’
‘ROOT::RDF::FromPandas’ is not a known C++ class
‘FromPandas’ is not a known C++ template
‘FromPandas’ is not a known C++ enum

Do you have any suggestion?

Hi,

I am sorry to read you are experiencing this issue.
What version of ROOT are you using?

A side question, originating from your code: could you maybe share the reason why you are starting from a ROOT file and you pass through uproot to build a RDataFrame?

Cheers,
Danilo

Hello!
I am using root 6.30/02.
For the second part of the question I am trying to integrate some stuff on old code i was given, basically what i wrote is not present in the extract i shared, i am just doing stuff with pandas (and I have to admit I am not quite familiar with python, I wrote my first line of code in Python 6 days ago), so for sure if you have any suggestions they are more than welcome!
Thank you again.

I got the code to run with

rdf = ROOT.RDF.FromNumpy(data)

but i figure it may not be the most elegant solution.

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