Logo ROOT  
Reference Guide
df024_Display.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_dataframe
3## \notebook
4## This tutorial shows how to use the Display action
5##
6## \macro_code
7## \macro_output
8##
9## \date August 2018
10## \author Enrico Guiraud, Danilo Piparo, Enric Tejedor Saavedra CERN, Massimo Tumolo Politecnico di Torino
11
12import ROOT
13
14# Setting up a Dataframe with some data
15ROOT.gInterpreter.ProcessLine('''
16 unsigned long long y = 1;
17 int x = 1;
18 double w = 1;
19 double z = 1;
20 ROOT::RDataFrame df(10);
21 auto d = df.Define("y", [&y]() { return y *= 100; }) // A column with ulongs
22 .Define("x",
23 [&x]() {
24 return std::vector<int>({x++, x++, x++, x++});
25 }) // A column with four-elements collection
26 .Define("w", [&w]() { return w *= 1.8; }) // A column with doubles
27 .Define("z", [&z]() {
28 z *= 1.1;
29 return std::vector<std::vector<double>>({{z, ++z}, {z, ++z}, {z, ++z}});
30 }); // A column of matrices
31''')
32
33d = ROOT.d
34
35# Preparing the RResultPtr<RDisplay> object with all columns and default number of entries
36d1 = d.Display("")
37# Preparing the RResultPtr<RDisplay> object with two columns and default number of entries
38cols = ROOT.vector('string')(); cols.push_back("x"); cols.push_back("y");
39d2 = d.Display(cols)
40
41# Printing the short representations, the event loop will run
42print("The following is the representation of all columns with the default nr of entries")
43d1.Print()
44print("\n\nThe following is the representation of two columns with the default nr of entries")
45d2.Print()