MultiprocessPandas
MultiprocessPandas package extends functionality of Pandas to easily run operations on multiple cores i.e. parallelize the operations. The current version of the package provides capability to parallelize apply() methods on DataFrames, Series and DataFrameGroupBy .
Importing the applyparallel module will add apply_parallel() method to DataFrame, Series and DataFrameGroupBy, which will allow you to run operation on multiple cores.
Installation
The package can be pulled from GitHub or can be installed from PyPi directly.
To install using pip
pip install multiprocesspandas
Setting up the Library
To use the library, you have to import applyparallel module. Import will attach required methods to pandas, and you can call them directly on Pandas data objects.
from multiprocesspandas import applyparallel
Usage
Once imported, the library adds functionality to call apply_parallel() method on your DataFrame, Series or DataFrameGroupBy . The methods accepts a function that has to be applied, and two named arguments:
- static_data (External Data required by passed function, defaults to None)
- num_processes (Defaults to maximum available cores on your CPU)
- axis (Only for DataFrames, defaults to 0 i.e. rows. For columns, set axis=1.
*Note: Any extra module required by the passed function must be re-imported again inside the function.*
Usage with DataFrameGroupBy
def func(x):
import pandas as pd
return pd.Series([x['C'].mean()])
df.groupby(["A","B"]).apply_parallel(func, num_processes=30)
If you need some external data inside func(), it has to be passed and received as position arguments or keyword arguments.
data1 = pd.Series([1,2,3])
data2 = 20
def func(x, data1, data2):
import pandas as pd
output = data1 - x['C'].mean()
return output * data2
df.groupby(["A","B"]).apply_parallel(func, data1=data1, data2=data2, num_processes=30)
Usage with DataFrame
Usage with DataFrames is very similar to the one with DataFrameGroupBy, however you have to pass an extra argument 'axis' which tells whether to apply function on the rows or the columns.
def func(x):
return x.mean()
df.apply_parallel(func, num_processes=30, axis=1)
External data can be passed in same way as we did in DataFrameGroupBy
data = pd.Series([1,2,3])
def func(x, data):
return data.sum() + x.mean()
df.apply_parallel(func, data=data, num_processes=30)
Usage with Series
Usage with Series is very similar to the usage with DataFrames and DataFrameGroupBy.
data = pd.Series([1,2,3])
def func(x, data):
return data-x
series.apply_parallel(func, data=data, num_processes=30)
Metadata
Release files for multiprocesspandas 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| multiprocesspandas-1.1.5.tar.gz | 4.4 kB | Without provenance | Details for multiprocesspandas-1.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| multiprocesspandas-1.1.5-py3-none-any.whl | Python 3 | none | any | Details for multiprocesspandas-1.1.5-py3-none-any.whl |
Total release size: 9.2 kB
Release files / multiprocesspandas-1.1.5.tar.gz
| Download URL | multiprocesspandas-1.1.5.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41d48b6ae3dfcdd899f01912cb8ee481caa3e4ebc837e37476d6c8d993ed3c68
|
|
BLAKE2b-256 checksum How to use checksums |
c76094517679ffa67edd31f7e469023ba7ed3b276feaba8cf1d9e72037601dc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / multiprocesspandas-1.1.5-py3-none-any.whl
| Download URL | multiprocesspandas-1.1.5-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f02c0a23c73ea6b34fc511d5af210a1066848323baa5a31e99e27c3d6a74820
|
|
BLAKE2b-256 checksum How to use checksums |
8840d40e3e061412f66478a648aed0e63193abebd771449bc04549ddc26b1a8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for multiprocesspandas 1.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.