The format I wanted was something like this:
Root file → 0 (tree named 0) → chn0, ch1, … (branches or leaves) which have the values shown in the csv file.
Please help me on how to approach this problem. Thank you.
Seems to me the ouput file you get looks like Comma Separated Value (csv). I am not sure to fully undertand what you are looking for. The documentation of MakeCsvDataFrame looks quite clear seems to me. May be @eguiraud can tell more.
If you have a pandas dataframe, create a dictionary where the keys are the names of the branches you’ll want in the root file, and the values are the numpy arrays extracted from the df column-by-column (with appropriate data cleaning and type conversion, if necessary).
Then, take this dictionary and pass it to this constructor rdf = ROOT.RDF.MakeNumpyDataFrame(DictOfBranches), with a following call rdf.Shapshot(treeName, fileName)