Python package ismember returns array elements that are members of set array.
Project description
ismember
- Python package ismember returns array elements that are members of set array
Contents
Installation
- Install ismember from PyPI (recommended). ismember is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
- It is distributed under the MIT license.
pip install ismember
- Alternatively, install ismember from the GitHub source:
git clone https://github.com/erdogant/ismember.git
cd ismember
python setup.py install
Import ismember package
from ismember import ismember
Example:
import numpy as np
from ismember import ismember
# Example with lists
a_vec = [1,2,3,None]
b_vec = [4,1,2]
[I,idx] = ismember(a_vec,b_vec)
np.array(a_vec)[I]
np.array(b_vec)[idx]
# Example with DataFrames
a_vec = pd.DataFrame(['aap','None','mies','aap','boom','mies',None,'mies','mies','pies',None])
b_vec = pd.DataFrame([None,'mies','mies','pies',None])
[I,idx] = ismember(a_vec,b_vec)
a_vec.values[I]
b_vec.values[idx]
a_vec = np.array([1,2,3,None])
b_vec = np.array([1,2,4])
[I,idx] = ismember(a_vec,b_vec)
a_vec[I]
b_vec[idx]
# Example with Numpy array
a_vec = np.array(['boom','aap','mies','aap'])
b_vec = np.array(['aap','boom','aap'])
[I,idx] = ismember(a_vec,b_vec)
a_vec[I]
b_vec[idx]
References
Maintainer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ismember-0.1.3.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file ismember-0.1.3.tar.gz
.
File metadata
- Download URL: ismember-0.1.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa36864058d5b5ee81764e81b10292cbccbd2d5f3761ef06c86eb4cd0fd662d |
|
MD5 | 8978fc802d04274fb620298b232d1ef8 |
|
BLAKE2b-256 | d59dd15715f5c9472e494711627be58a87eac3de142d8d95cfa9b95744fea5fe |
File details
Details for the file ismember-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: ismember-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4446caa8de5f7c7f35eae6a1fe28f72a0410d3f77fe0036a51b5f2b58a6cb95 |
|
MD5 | e0b09369be4c18e490b7c5e1f1a7f353 |
|
BLAKE2b-256 | d864607c4f96a74583dd49808d6f40b6d88ef6f4393c62ef16eba2ceaec3f5ae |