Commit suggestion
@@ -224,16 +224,10 @@ class Step(object):
collections = {}
+ baseline = {ent: "n/a" for ent in ent_cols}
for name, contrasts in groups.items():
# Create a DF with contrasts in rows and contrast names in columns
- data = []
- for c in contrasts:
- c_data = {**c.entities, **{c.name: 1}}
- for ent in ent_cols:
- if ent not in c_data:
- c_data[ent] = 'n/a'
- data.append(c_data)
-
+ data = [{**baseline, **c.entities, **{c.name: 1}} for c in contrasts]
data = pd.DataFrame.from_records(data)
# Group by all entities and sum, collapsing over rows belonging
# to the current unit
