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