mapply
mapply provides a sensible multi-core apply function for Pandas.
mapply vs. pandarallel vs. swifter
Where pandarallel relies on in-house multiprocessing and progressbars, and hard-codes 1 chunk per worker (which will cause idle CPUs when one chunk happens to be more expensive than the others), swifter relies on the heavy dask framework for multiprocessing (converting to Dask DataFrames and back). In an attempt to find the golden mean, mapply is highly customizable and remains lightweight, using tqdm for progressbars and leveraging the powerful pathos framework, which shadows Python's built-in multiprocessing module using dill for universal pickling.
Installation
This pure-Python, OS independent package is available on PyPI:
$ pip install mapply
Usage
For documentation, see mapply.readthedocs.io.
import pandas as pd
import mapply
mapply.init(
n_workers=-1,
chunk_size=100,
max_chunks_per_worker=8,
progressbar=False
)
df = pd.DataFrame({"A": list(range(100))})
# avoid unnecessary multiprocessing:
# due to chunk_size=100, this will act as regular apply.
# set chunk_size=1 to skip this check and let max_chunks_per_worker decide.
df["squared"] = df.A.mapply(lambda x: x ** 2)
Development
Run make help for options like installing for development, linting, testing, and building docs.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mapply-0.1.23.tar.gz.
File metadata
- Download URL: mapply-0.1.23.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7ebae949aa64fdfc7f2a579ae42e6d8f55bd5e91f8cb77def968801f892306c
|
|
| MD5 |
4c410618bb1fcab3aa17440b3454c20c
|
|
| BLAKE2b-256 |
039c58bc25b79912f789da6d7dab60c8cf1d6fc12f98653f1acb731d6eec4bc9
|
File details
Details for the file mapply-0.1.23-py3-none-any.whl.
File metadata
- Download URL: mapply-0.1.23-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1907984a435d079693ca38f14d36728faf2e61daa60e900d766bfebe90aee421
|
|
| MD5 |
cd05d61ab8eac2000e64f33022ca1128
|
|
| BLAKE2b-256 |
f4f230718b70b96c1b6be57ffc02664bf357d111b5904a8b1d3dc76b183d11fd
|