PyFunctional

1.5.0 · active · verified Tue Apr 14

PyFunctional is a Python package designed for creating data pipelines using a functional programming paradigm, inspired by Scala and Spark. It provides tools for chaining operations on sequences, supporting lazy evaluation, parallel processing, and various data transformations. The current version is 1.5.0, and the project generally focuses on API stability since its 1.0.0 release.

Warnings

Install

Imports

Quickstart

This example demonstrates creating a sequence, applying common functional transformations like `map` and `filter`, and finally aggregating results with `reduce`.

from functional import seq

# Create a sequence from a range of numbers
result = seq(range(10))
    .map(lambda x: x * x) # Square each number
    .filter(lambda x: x > 10) # Keep numbers greater than 10
    .reduce(lambda x, y: x + y, 0) # Sum the remaining numbers, starting with 0

print(result)
# Expected output: 285

view raw JSON →