mapply
mapply provides sensible multi-core apply/map/applymap functions for Pandas.
mapply vs. pandarallel vs. swifter
Where pandarallel only requires dill (and therefore has to rely on in-house multiprocessing and progressbars), swifter relies on the heavy dask framework, converting to Dask DataFrames and back. In an attempt to find the golden mean, mapply is highly customizable and remains lightweight, 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.9.tar.gz.
File metadata
- Download URL: mapply-0.1.9.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c18fa65b91be6ac56254c1b85924c7e31c2e7e124ef9f8d074566abc1c49b5d
|
|
| MD5 |
b8b8709e03f16d48ffd8bd70840bb8c4
|
|
| BLAKE2b-256 |
93525bd5d53832a8e89008ceb9b7733d4dd5d219bd9d50293f3d9009b99598ba
|
File details
Details for the file mapply-0.1.9-py3-none-any.whl.
File metadata
- Download URL: mapply-0.1.9-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6404a1af3388a90a2dd55a294907e4b7161e51149f848ebd04cf390cead7404a
|
|
| MD5 |
acae47e44e01f2b6091eaef77bcf5248
|
|
| BLAKE2b-256 |
6677f5a5965bd2df225113c31814bcec9c4c856e929d8866d83dcd14de21ffac
|