Skip to content

Commit 1ba0686

Browse files
author
miranov25
committed
supressing linter warning
1 parent 350f786 commit 1ba0686

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

UTILS/dfextensions/AliasDataFrame.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""timeseries_diff.py
1+
""" AliasDataframe.py
22
import sys,os; sys.path.insert(1, os.environ[f"O2DPG"]+"/UTILS/dfextensions");
33
from AliasDataFrame import *
44
Utility helpers extension of the pandas DataFrame to support on-demand computed columns (aliases)
@@ -7,15 +7,13 @@
77
import pandas as pd
88
import numpy as np
99
import json
10-
import os
1110
import uproot
12-
11+
import ROOT # type: ignore
1312
class AliasDataFrame:
1413
"""
1514
A wrapper for pandas DataFrame that supports on-demand computed columns (aliases)
1615
with dependency tracking and persistence.
1716
Example usage:
18-
>>> import pandas as pd
1917
>>> df = pd.DataFrame({"x": [1, 2, 3], "y": [10, 20, 30]})
2018
>>> adf = AliasDataFrame(df)
2119
>>> adf.add_alias("z", "x + y")
@@ -174,16 +172,16 @@ def export_tree(self, filename, treename="tree", dropAliasColumns=True):
174172

175173
with uproot.recreate(filename) as f:
176174
f[treename] = export_df
177-
178-
import ROOT
175+
# Update the ROOT file with aliases
179176
f = ROOT.TFile.Open(filename, "UPDATE")
180177
tree = f.Get(treename)
181178
for alias, expr in self.aliases.items():
182179
tree.SetAlias(alias, expr)
183180
tree.Write("", ROOT.TObject.kOverwrite)
184181
f.Close()
185182

186-
def read_tree(self, filename, treename="tree"):
183+
@staticmethod
184+
def read_tree(filename, treename="tree"):
187185
with uproot.open(filename) as f:
188186
df = f[treename].arrays(library="pd")
189187
adf = AliasDataFrame(df)

0 commit comments

Comments
 (0)