

def root2pandas(file_name):
    'Reads some ROOT file to pandas, finds the first tree and converts it.'
    with rootpy.io.root_open(file_name, 'READ') as root_file:
        for (path, dirs, objects) in root_file.walk():
            for objName in objects:
                obj = root_file.Get(((path + '/') + objName))
                if isinstance(obj, rootpy.tree.Tree):
                    print(((('Adding a tree named ' + objName) + ' from file ') + file_name))
                    tree = dirs
                    numpy_array = tree.to_array()
                    dataframe = pandas.DataFrame(numpy_array)
                    print('success, features:', len(dataframe.columns), 'events', len(dataframe))
                    return dataframe
    raise RuntimeError('Nothing found in the file {}'.format(file_name))

dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/rootutilities.py root2pandas/VarMisuse@102/174 `obj`->`dirs`