{ "cells": [ { "cell_type": "markdown", "id": "8d403bd0", "metadata": {}, "source": [ "# df008_createDataSetFromScratch\n", "Create data from scratch with RDataFrame.\n", "\n", "This tutorial shows how to create a dataset from scratch with RDataFrame\n", "\n", "\n", "\n", "\n", "**Author:** Danilo Piparo (CERN) \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:09 PM." ] }, { "cell_type": "markdown", "id": "984c6eaf", "metadata": {}, "source": [ "We create an empty data frame of 100 entries" ] }, { "cell_type": "code", "execution_count": 1, "id": "fd4136c9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:09:35.133380Z", "iopub.status.busy": "2026-05-19T20:09:35.133235Z", "iopub.status.idle": "2026-05-19T20:09:35.475145Z", "shell.execute_reply": "2026-05-19T20:09:35.469388Z" } }, "outputs": [], "source": [ "ROOT::RDataFrame df(100);" ] }, { "cell_type": "markdown", "id": "01bc4981", "metadata": {}, "source": [ "We now fill it with random numbers" ] }, { "cell_type": "code", "execution_count": 2, "id": "8217da44", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:09:35.492400Z", "iopub.status.busy": "2026-05-19T20:09:35.492257Z", "iopub.status.idle": "2026-05-19T20:09:35.967645Z", "shell.execute_reply": "2026-05-19T20:09:35.967043Z" } }, "outputs": [], "source": [ "gRandom->SetSeed(1);\n", "auto df_1 = df.Define(\"rnd\", []() { return gRandom->Gaus(); });" ] }, { "cell_type": "markdown", "id": "cfbd99a7", "metadata": {}, "source": [ "And we write out the dataset on disk" ] }, { "cell_type": "code", "execution_count": 3, "id": "46ad2f08", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:09:35.969448Z", "iopub.status.busy": "2026-05-19T20:09:35.969322Z", "iopub.status.idle": "2026-05-19T20:09:37.110737Z", "shell.execute_reply": "2026-05-19T20:09:37.110120Z" } }, "outputs": [], "source": [ "df_1.Snapshot(\"randomNumbers\", \"df008_createDataSetFromScratch.root\");" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }