INNER CODE UNIT · Python

group_by

panther-labs/panther-analysis · .scripts/generate_indexes.py:226

def group_by(iterable, key=None):
    # Uses itertools.groupby to produce a dictionary where each key is the grouping defined by the key function
    if key is None:
        key = lambda x: x
    result = {}
    data = sorted(iterable, key=key)
    groups = itertools.groupby(data, key=key)
    for k, g in groups:
        result[k] = list(g)
    return result


def save_website_json(detections, query_lookup, logtype_lookup, json_path):
    json_export = []
    detection_types = collections.Counter()

    for d in detections.values():
        json_slice = {key: d[key] for key in

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…