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.
pip install pyfunctionalVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating a sequence, applying common functional transformations like `map` and `filter`, and finally aggregating results with `reduce`.
Update `pip install scalafunctional` to `pip install pyfunctional` and change `from scalafunctional import ...` to `from functional import ...`.
Replace calls to `Sequence.zip_with_index()` with Python's built-in `enumerate()` for equivalent functionality.
To force immediate evaluation for debugging or specific needs, append an action like `.to_list()` or `.to_dict()` at the point where you need the results.
If your pipeline operations are CPU-bound and you want to leverage multiple cores, ensure your pipeline starts with `from functional import pseq` and use `pseq(...)`.
Ensure that any functions used with `pseq` are defined within the `if __name__ == '__main__':` block in your main script, or are imported from a separate module that can be safely imported by worker processes. For `lambda` functions, consider defining them as top-level `def` functions if they need to be serialized across processes.
To force the execution of the pipeline and get the results, append an action method to the end of your functional chain, such as `.to_list()`, `.to_dict()`, `.reduce()`, or iterate over the `seq` object.
Review the type of the object at the point the `TypeError` is raised. Ensure that functions passed to `map`, `filter`, or other transformation methods are indeed callable, and that the arguments they receive are of the expected type. Also, ensure the input to `seq()` is an iterable.
To fix `ModuleNotFoundError`, install the package using `pip install pyfunctional`. To fix `AttributeError` for `seq` or `pseq`, ensure you are using the correct import statement: `from functional import seq` for standard pipelines or `from functional import pseq` for parallel processing.
No dependency data recorded yet.