{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3d4adc5a",
   "metadata": {},
   "source": [
    "# df024_Display\n",
    "Use the Display action to inspect entry values.\n",
    "\n",
    "This tutorial shows how to use the Display action\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "**Author:**  Enrico Guiraud, Danilo Piparo, Enric Tejedor Saavedra (CERN), Massimo Tumolo (Politecnico di Torino)  \n",
    "<i><small>This notebook tutorial was automatically generated with <a href= \"https://github.com/root-project/root/blob/master/documentation/doxygen/converttonotebook.py\">ROOTBOOK-izer</a> from the macro found in the ROOT repository  on Tuesday, May 19, 2026 at 08:09 PM.</small></i>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6b411ac2",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:00.951032Z",
     "iopub.status.busy": "2026-05-19T20:10:00.950912Z",
     "iopub.status.idle": "2026-05-19T20:10:01.945863Z",
     "shell.execute_reply": "2026-05-19T20:10:01.945452Z"
    }
   },
   "outputs": [],
   "source": [
    "import ROOT"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf0f43d4",
   "metadata": {},
   "source": [
    "Setting up a Dataframe with some data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d69dcf84",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:01.962255Z",
     "iopub.status.busy": "2026-05-19T20:10:01.962093Z",
     "iopub.status.idle": "2026-05-19T20:10:02.840000Z",
     "shell.execute_reply": "2026-05-19T20:10:02.839626Z"
    }
   },
   "outputs": [],
   "source": [
    "ROOT.gInterpreter.ProcessLine('''\n",
    "   unsigned long long y = 1;\n",
    "   int x = 1;\n",
    "   double w = 1;\n",
    "   double z = 1;\n",
    "   ROOT::RDataFrame df(10);\n",
    "   auto d = df.Define(\"y\", [&y]() { return y *= 100; }) // A column with ulongs\n",
    "              .Define(\"x\",\n",
    "                      [&x]() {\n",
    "                         return std::vector<int>({x++, x++, x++, x++});\n",
    "                      })                                // A column with four-elements collection\n",
    "              .Define(\"w\", [&w]() { return w *= 1.8; }) // A column with doubles\n",
    "              .Define(\"z\", [&z]() {\n",
    "                 z *= 1.1;\n",
    "                 return std::vector<std::vector<double>>({{z, ++z}, {z, ++z}, {z, ++z}});\n",
    "              }); // A column of matrices\n",
    "''')\n",
    "\n",
    "d = ROOT.d"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb529741",
   "metadata": {},
   "source": [
    "Preparing the RResultPtr<RDisplay> object with all columns and default number of entries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f5b26fa4",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:02.852367Z",
     "iopub.status.busy": "2026-05-19T20:10:02.852229Z",
     "iopub.status.idle": "2026-05-19T20:10:03.191352Z",
     "shell.execute_reply": "2026-05-19T20:10:03.179666Z"
    }
   },
   "outputs": [],
   "source": [
    "d1 = d.Display(\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e01d91ce",
   "metadata": {},
   "source": [
    "Preparing the RResultPtr<RDisplay> object with two columns and default number of entries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2647e8be",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:03.204367Z",
     "iopub.status.busy": "2026-05-19T20:10:03.204211Z",
     "iopub.status.idle": "2026-05-19T20:10:03.359837Z",
     "shell.execute_reply": "2026-05-19T20:10:03.359461Z"
    }
   },
   "outputs": [],
   "source": [
    "cols = ROOT.vector('string')(); cols.push_back(\"x\"); cols.push_back(\"y\");\n",
    "d2 = d.Display(cols)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8db273f2",
   "metadata": {},
   "source": [
    "Printing the short representations, the event loop will run"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d1c15d7c",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:03.373020Z",
     "iopub.status.busy": "2026-05-19T20:10:03.372880Z",
     "iopub.status.idle": "2026-05-19T20:10:04.630195Z",
     "shell.execute_reply": "2026-05-19T20:10:04.629454Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The following is the representation of all columns with the default nr of entries\n",
      "\n",
      "\n",
      "The following is the representation of two columns with the default nr of entries\n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| Row | w         | x  | y           | z                        | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| 0   | 1.800000  | 1  | 100         | { 1.1000000, 2.1000000 } | \n",
      "|     |           | 2  |             | { 2.1000000, 3.1000000 } | \n",
      "|     |           | 3  |             | { 3.1000000, 4.1000000 } | \n",
      "|     |           | 4  |             |                          | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| 1   | 3.240000  | 5  | 10000       | { 4.5100000, 5.5100000 } | \n",
      "|     |           | 6  |             | { 5.5100000, 6.5100000 } | \n",
      "|     |           | 7  |             | { 6.5100000, 7.5100000 } | \n",
      "|     |           | 8  |             |                          | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| 2   | 5.832000  | 9  | 1000000     | { 8.2610000, 9.2610000 } | \n",
      "|     |           | 10 |             | { 9.2610000, 10.261000 } | \n",
      "|     |           | 11 |             | { 10.261000, 11.261000 } | \n",
      "|     |           | 12 |             |                          | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| 3   | 10.497600 | 13 | 100000000   | { 12.387100, 13.387100 } | \n",
      "|     |           | 14 |             | { 13.387100, 14.387100 } | \n",
      "|     |           | 15 |             | { 14.387100, 15.387100 } | \n",
      "|     |           | 16 |             |                          | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "| 4   | 18.895680 | 17 | 10000000000 | { 16.925810, 17.925810 } | \n",
      "|     |           | 18 |             | { 17.925810, 18.925810 } | \n",
      "|     |           | 19 |             | { 18.925810, 19.925810 } | \n",
      "|     |           | 20 |             |                          | \n",
      "+-----+-----------+----+-------------+--------------------------+\n",
      "+-----+----+-------------+\n",
      "| Row | x  | y           | \n",
      "+-----+----+-------------+\n",
      "| 0   | 1  | 100         | \n",
      "|     | 2  |             | \n",
      "|     | 3  |             | \n",
      "|     | 4  |             | \n",
      "+-----+----+-------------+\n",
      "| 1   | 5  | 10000       | \n",
      "|     | 6  |             | \n",
      "|     | 7  |             | \n",
      "|     | 8  |             | \n",
      "+-----+----+-------------+\n",
      "| 2   | 9  | 1000000     | \n",
      "|     | 10 |             | \n",
      "|     | 11 |             | \n",
      "|     | 12 |             | \n",
      "+-----+----+-------------+\n",
      "| 3   | 13 | 100000000   | \n",
      "|     | 14 |             | \n",
      "|     | 15 |             | \n",
      "|     | 16 |             | \n",
      "+-----+----+-------------+\n",
      "| 4   | 17 | 10000000000 | \n",
      "|     | 18 |             | \n",
      "|     | 19 |             | \n",
      "|     | 20 |             | \n",
      "+-----+----+-------------+\n"
     ]
    }
   ],
   "source": [
    "print(\"The following is the representation of all columns with the default nr of entries\")\n",
    "d1.Print()\n",
    "print(\"\\n\\nThe following is the representation of two columns with the default nr of entries\")\n",
    "d2.Print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "005142bc",
   "metadata": {},
   "source": [
    "Draw all canvases "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "02af604b",
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2026-05-19T20:10:04.631514Z",
     "iopub.status.busy": "2026-05-19T20:10:04.631379Z",
     "iopub.status.idle": "2026-05-19T20:10:04.754399Z",
     "shell.execute_reply": "2026-05-19T20:10:04.739216Z"
    }
   },
   "outputs": [],
   "source": [
    "from ROOT import gROOT \n",
    "gROOT.GetListOfCanvases().Draw()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
