xarray extension for data comparison
Project description
xarray-compare
xarray extension for data comparison
TL;DR
xarray-compare is a third-party Python package which provides extra data-comparison features.
After importing the package, several DataArray methods (dataarray.is*()
) will be available.
Requirements
- Python: 3.6, 3.7, or 3.8 (tested by the author)
- Dependencies: See pyproject.toml
Installation
$ pip install xarray-compare
List of available methods
.isbetween(lower, upper)
: Test whether each value in a DataArray falls within an interval.ismatch(pattern)
: Test whether each string in a DataArray matches a regex pattern
Methods of "not-in" version are also provided for readability.
.isnotin(values)
: Equivalent to~dataarray.isin(values)
(.isin()
is an xarray's builtin).isnotbetween(lower, upper)
: Equivalent to~dataarray.isbetween(lower, upper)
.isnotmatch(pattern)
: Equivalent to~dataarray.ismatch(pattern)
Examples
xarray-compare is a just-import package. After importing it, methods become available from normal DataArray instances.
import xarray as xr
import xarray_compare
A method returns a boolean DataArray each value of which is True
where that of the input DataArray fulfills the condition and False
otherwise.
This is why it works well with the dataarray.where()
method.
da = xr.DataArray([0, 1, 1, 2, 3, 5, 8, 13])
da.where(da.isbetween(1, 4), drop=True)
# <xarray.DataArray (dim_0: 4)>
# array([1., 1., 2., 3.])
# Dimensions without coordinates: dim_0
da = xr.DataArray(['a', 'aa', 'ab', 'bc'])
da.where(da.ismatch("^a+$"), drop=True)
# <xarray.DataArray (dim_0: 2)>
# array(['a', 'aa'], dtype=object)
# Dimensions without coordinates: dim_0
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
Built Distribution
File details
Details for the file xarray-compare-0.1.1.tar.gz
.
File metadata
- Download URL: xarray-compare-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.8 Linux/5.3.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3b72e8659347bbe66887161728555ca074225170381225c9b8d8e63ee195012 |
|
MD5 | dc80153dcb07f3e90530c59be1678da0 |
|
BLAKE2b-256 | 201396c46cffbcc9c4218712109c3da72cffc524fd84f042a7ad1e5313ef635a |
File details
Details for the file xarray_compare-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: xarray_compare-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.8 Linux/5.3.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12f15cd75e45771e0f701f2ed46d6a634aefe30ba4bdf84a9ce7769951860e27 |
|
MD5 | da92eb82663fc256399efb7192265e69 |
|
BLAKE2b-256 | 85281d8aeaf30ce712995c772e0009d6e17b1c23d2b693232019846543c8f01e |