gordonwatts / BDTTrainingAnalysisLanguage

Pull from ATLAS EXOT 15 Derivation, columnar data, and flat rootutples with RDF to scikitlearn in one nice fast swoop
0 stars 2 forks source link

Simplify nested SelectMany queries that end in Select #35

Closed gordonwatts closed 5 years ago

gordonwatts commented 5 years ago

The following two queries are the same:

training_df = events \
    .SelectMany('lambda e: e.Jets("AntiKt4EMTopoJets").Select(lambda j1: (j1, j1))') \
    .Select('lambda j: j[0].pt()') \
    .AsPandasDF(columns=['JetPt']).value()

and

training_df = events \
    .SelectMany('lambda e: e.Jets("AntiKt4EMTopoJets")') \
    .Select(lambda j1: (j1, j1)) \
    .Select('lambda j: j[0].pt()') \
    .AsPandasDF(columns=['JetPt']).value()

However, the nested nature means they are a bit painful to implement - why not make them the same by doing a transform.

NOTE: this will little tricky if the moved lambda function captures anything from the first statement! This will have to be addressed when working on #30.