I refer to extract_info where I extracted information by using a for loop. Is there a way to extract information without reading entry by entry in a for loop? for example reading the data as a matrix?
Christian
I refer to extract_info where I extracted information by using a for loop. Is there a way to extract information without reading entry by entry in a for loop? for example reading the data as a matrix?
Christian
Hi,
Thanks for your answer. I solved this problem by using uproot. I found it very useful to manage arrays to create dataframe with pandas. Here, the function in python that I wrote:
def read_root_to_df (fname, treename="treename"):
# read file, get tree and list of branches
ntuple=uproot.open(fname)
tree=ntuple[treename]
col_list=tree.keys()
# fill dict. with array from branches
df_values = {}
for col in col_list:
df_values[col]=tree[col].array()
# Create the dataframe.
df = pd.DataFrame.from_dict(df_values)
return df
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.