I’m having a problem to create a TGraph from pandas dataframe.
This is the part of the code, where I read the data with pandas, I convert the 2 columns in array in order to pass them to the TGraph:
import pandas as pd
df=pd.read_csv(csv_off, sep=’\t’)
not sure what the cause could be. Anyway, perhaps the best solution would be to use RDataFrame directly in ROOT:
import ROOT
MakeCsvDataFrame = ROOT.ROOT.RDF.MakeCsvDataFrame
# here it depends if you have headers for your columns or not
hasHeaders=false
df = MakeCsvDataFrame("myTextInput", hasHeaders, "\t")
# again here we assume you do not have headers
g = df.Graph("Col0", "Col1")
canvas= ROOT.TCanvas()
g.Draw(“APE”)
canvas.SaveAs(“p.png”)