Df 0 2 4_ Display

This tutorial shows how to use the Display action

Author: Enrico Guiraud, Danilo Piparo, Enric Tejedor Saavedra CERN, Massimo Tumolo Politecnico di Torino
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, January 27, 2020 at 01:17 AM.

In [1]:
import ROOT
Welcome to JupyROOT 6.19/01

Setting up a Dataframe with some data

In [2]:
ROOT.gInterpreter.ProcessLine('''
   unsigned long long y = 1;
   int x = 1;
   double w = 1;
   double z = 1;
   ROOT::RDataFrame tdf(10);
   auto d = tdf.Define("y", [&y]() { return y *= 100; }) // A column with ulongs
               .Define("x",
                       [&x]() {
                          return std::vector<int>({x++, x++, x++, x++});
                       })                                // A column with four-elements collection
               .Define("w", [&w]() { return w *= 1.8; }) // A column with doubles
               .Define("z", [&z]() {
                  z *= 1.1;
                  return std::vector<std::vector<double>>({{z, ++z}, {z, ++z}, {z, ++z}});
               }); // A column of matrices
''')

d = ROOT.d

Preparing the RResultPtr object with all columns and default number of entries

In [3]:
d1 = d.Display("")

Preparing the RResultPtr object with two columns and default number of entries

In [4]:
cols = ROOT.vector('string')(); cols.push_back("x"); cols.push_back("y");
d2 = d.Display(cols)

Printing the short representations, the event loop will run

In [5]:
print("The following is the representation of all columns with the default nr of entries")
d1.Print()
print("\n\nThe following is the representation of two columns with the default nr of entries")
d2.Print()
The following is the representation of all columns with the default nr of entries


The following is the representation of two columns with the default nr of entries
y           | x   | w         | z                        | 
100         | 1   | 1.8000000 | { 1.1000000, 2.1000000 } | 
            | ... |           | ...                      | 
            | 4   |           | { 3.1000000, 4.1000000 } | 
10000       | 5   | 3.2400000 | { 4.5100000, 5.5100000 } | 
            | ... |           | ...                      | 
            | 8   |           | { 6.5100000, 7.5100000 } | 
1000000     | 9   | 5.8320000 | { 8.2610000, 9.2610000 } | 
            | ... |           | ...                      | 
            | 12  |           | { 10.261000, 11.261000 } | 
100000000   | 13  | 10.497600 | { 12.387100, 13.387100 } | 
            | ... |           | ...                      | 
            | 16  |           | { 14.387100, 15.387100 } | 
10000000000 | 17  | 18.895680 | { 16.925810, 17.925810 } | 
            | ... |           | ...                      | 
            | 20  |           | { 18.925810, 19.925810 } | 
x   | y           | 
1   | 100         | 
... |             | 
4   |             | 
5   | 10000       | 
... |             | 
8   |             | 
9   | 1000000     | 
... |             | 
12  |             | 
13  | 100000000   | 
... |             | 
16  |             | 
17  | 10000000000 | 
... |             | 
20  |             | 

Draw all canvases

In [6]:
from ROOT import gROOT 
gROOT.GetListOfCanvases().Draw()