data-manipulation-utilities 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: data_manipulation_utilities
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Description-Content-Type: text/markdown
5
5
  Requires-Dist: logzero
6
6
  Requires-Dist: PyYAML
@@ -1,4 +1,4 @@
1
- data_manipulation_utilities-0.1.4.data/scripts/publish,sha256=-3K_Y2_4CfWCV50rPB8CRuhjxDu7xMGswinRwPovgLs,1976
1
+ data_manipulation_utilities-0.1.5.data/scripts/publish,sha256=-3K_Y2_4CfWCV50rPB8CRuhjxDu7xMGswinRwPovgLs,1976
2
2
  dmu/arrays/utilities.py,sha256=PKoYyybPptA2aU-V3KLnJXBudWxTXu4x1uGdIMQ49HY,1722
3
3
  dmu/generic/utilities.py,sha256=0Xnq9t35wuebAqKxbyAiMk1ISB7IcXK4cFH25MT1fgw,1741
4
4
  dmu/logging/log_store.py,sha256=v0tiNz-6ktT_afD5DuvCZ8Nmr82JKQOPli8hgd28P1Q,3960
@@ -10,7 +10,7 @@ dmu/plotting/plotter.py,sha256=laa6Kl7P-ZOIhaOFBVjOH4XQ4kPCV7wBNvLIMBnyCwM,7181
10
10
  dmu/plotting/plotter_1d.py,sha256=G-i94uzm2TjNaog1A4agAKar_G0qNdkAqIPCmzhe85Y,3660
11
11
  dmu/plotting/plotter_2d.py,sha256=SWPKns-CfpUZHgBXvwm3gceH3k2eL_mKGXQ8sWpZJB0,2919
12
12
  dmu/rdataframe/atr_mgr.py,sha256=FdhaQWVpsm4OOe1IRbm7rfrq8VenTNdORyI-lZ2Bs1M,2386
13
- dmu/rdataframe/utilities.py,sha256=a31PdUz12sC2bx78LK6gvACh1M_eFaIVwuZEvOTcvcc,2084
13
+ dmu/rdataframe/utilities.py,sha256=x8r379F2-vZPYzAdMFCn_V4Kx2Tx9t9pn_QHcZ1euew,2756
14
14
  dmu/rfile/rfprinter.py,sha256=vGdqyHT_GwGBhrY7KG63EAUGWEOqobz_5yTL6goXbfk,2722
15
15
  dmu/rfile/utilities.py,sha256=XuYY7HuSBj46iSu3c60UYBHtI6KIPoJU_oofuhb-be0,945
16
16
  dmu/stats/fitter.py,sha256=LDvFNyhgO0OzXN7aH3kfHe6LzuPqdQfPcKR_IegDcaU,18204
@@ -39,8 +39,8 @@ dmu_scripts/rfile/compare_root_files.py,sha256=T8lDnQxsRNMr37x1Y7YvWD8ySHrJOWZki
39
39
  dmu_scripts/rfile/print_trees.py,sha256=Ze4Ccl_iUldl4eVEDVnYBoe4amqBT1fSBR1zN5WSztk,941
40
40
  dmu_scripts/ssh/coned.py,sha256=lhilYNHWRCGxC-jtyJ3LQ4oUgWW33B2l1tYCcyHHsR0,4858
41
41
  dmu_scripts/text/transform_text.py,sha256=9akj1LB0HAyopOvkLjNOJiptZw5XoOQLe17SlcrGMD0,1456
42
- data_manipulation_utilities-0.1.4.dist-info/METADATA,sha256=22y3wi2wh7fXUPYixxLJVDr0qyu0eeicGikPI4phUvg,19946
43
- data_manipulation_utilities-0.1.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
- data_manipulation_utilities-0.1.4.dist-info/entry_points.txt,sha256=1TIZDed651KuOH-DgaN5AoBdirKmrKE_oM1b6b7zTUU,270
45
- data_manipulation_utilities-0.1.4.dist-info/top_level.txt,sha256=n_x5J6uWtSqy9mRImKtdA2V2NJNyU8Kn3u8DTOKJix0,25
46
- data_manipulation_utilities-0.1.4.dist-info/RECORD,,
42
+ data_manipulation_utilities-0.1.5.dist-info/METADATA,sha256=FDasFTGm3SS2psyLpYbGkWFuKw42ejctM5_mJUEY_9Y,19946
43
+ data_manipulation_utilities-0.1.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
+ data_manipulation_utilities-0.1.5.dist-info/entry_points.txt,sha256=1TIZDed651KuOH-DgaN5AoBdirKmrKE_oM1b6b7zTUU,270
45
+ data_manipulation_utilities-0.1.5.dist-info/top_level.txt,sha256=n_x5J6uWtSqy9mRImKtdA2V2NJNyU8Kn3u8DTOKJix0,25
46
+ data_manipulation_utilities-0.1.5.dist-info/RECORD,,
@@ -4,11 +4,13 @@ Module containing utility functions to be used with ROOT dataframes
4
4
 
5
5
  import re
6
6
  from dataclasses import dataclass
7
+ from typing import Union
7
8
 
9
+ import pandas as pnd
8
10
  import awkward as ak
9
11
  import numpy
10
12
 
11
- from ROOT import RDataFrame
13
+ from ROOT import RDataFrame, RDF
12
14
 
13
15
  from dmu.logging.log_store import LogStore
14
16
 
@@ -23,7 +25,7 @@ class Data:
23
25
  l_good_type = [int, numpy.bool_, numpy.int32, numpy.uint32, numpy.int64, numpy.uint64, numpy.float32, numpy.float64]
24
26
  d_cast_type = {'bool': numpy.int32}
25
27
  # ---------------------------------------------------------------------
26
- def add_column(rdf : RDataFrame, arr_val : numpy.ndarray | None, name : str, d_opt : dict | None = None):
28
+ def add_column(rdf : RDataFrame, arr_val : Union[numpy.ndarray,None], name : str, d_opt : Union[dict,None] = None):
27
29
  '''
28
30
  Will take a dataframe, an array of numbers and a string
29
31
  Will add the array as a colunm to the dataframe
@@ -70,3 +72,24 @@ def add_column(rdf : RDataFrame, arr_val : numpy.ndarray | None, name : str, d_o
70
72
 
71
73
  return rdf
72
74
  # ---------------------------------------------------------------------
75
+ def rdf_report_to_df(rep : RDF.RCutFlowReport) -> pnd.DataFrame:
76
+ '''
77
+ Takes the output of rdf.Report(), i.e. an RDataFrame cutflow report.
78
+
79
+ Produces a pandas dataframe with
80
+ '''
81
+ d_data = {'cut' : [], 'All' : [], 'Passed' : []}
82
+ for cut in rep:
83
+ name=cut.GetName()
84
+ pas =cut.GetPass()
85
+ tot =cut.GetAll()
86
+
87
+ d_data['cut' ].append(name)
88
+ d_data['All' ].append(tot)
89
+ d_data['Passed'].append(pas)
90
+
91
+ df = pnd.DataFrame(d_data)
92
+ df['Efficiency' ] = df['Passed'] / df['All']
93
+ df['Cummulative'] = df['Efficiency'].cumprod()
94
+
95
+ return df