Skip to content

[Documentation] Use exeutorlib with pandas Dataframes #928

@jan-janssen

Description

@jan-janssen

Add an example how to use executorlib with Pandas Dataframes:

import pandas
from executorlib import SingleNodeExecutor

def compute(a, b):
    return (a-b) / (a+b)

df = pandas.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df["c"] = df[["a", "b"]].apply(lambda x: compute(x.a, x.b), axis=1)

The same can be done with Executorlib using:

with SingleNodeExecutor() as exe:
    df["c"] = list(exe.map(compute, df["a"], df["b"]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions