ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
df035_RDFFromPandas.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_dataframe
3
## \notebook
4
## Read data from Pandas Data Frame into RDataFrame.
5
##
6
## \macro_code
7
## \macro_output
8
##
9
## \date February 2024
10
## \author Pere Mato (CERN)
11
12
import
ROOT
13
import
pandas
as
pd
14
15
# Let's create some data in a pandas dataframe
16
pdf =
pd.DataFrame
({
'x'
: [1, 2, 3],
'y'
: [4, 5, 6]})
17
18
# Convert the Pandas DataFrame to RDataFrame
19
# The column names are directly copied to the RDF
20
# Please note that only fundamental types (int, float, ...) are supported and
21
# the arrays must have the same length.
22
df =
ROOT.RDF.FromPandas
(pdf)
23
24
# You can now use the RDataFrame as usually, e.g. add a column ...
25
df =
df.Define
(
'z'
,
'x + y'
)
26
27
# ... or print the content
28
df.Display
().
Print
()
29
30
# ... or save the data as a ROOT file
31
df.Snapshot
(
'tree'
,
'df035_RDFFromPandas.root'
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
Print
void Print(GNN_Data &d, std::string txt="")
Definition
TMVA_SOFIE_GNN_Application.C:59
tutorials
dataframe
df035_RDFFromPandas.py
ROOT v6-32 - Reference Guide Generated on Mon Apr 7 2025 15:28:17 (GVA Time) using Doxygen 1.10.0