Skip to main content

xarray extension for data comparison

Project description

xarray-compare

PyPI Python Test License DOI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray-compare-0.2.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

xarray_compare-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file xarray-compare-0.2.0.tar.gz.

File metadata

  • Download URL: xarray-compare-0.2.0.tar.gz
  • Upload date:
  • Size: 4.8 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

Hashes for xarray-compare-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d7826eda0fe9cf528526a19ad60d4a0dfef37b6caee46cc1d0907a101aec3ee0
MD5 f6ebd8c538d139c52fbb1941d7ef6a34
BLAKE2b-256 695fef313113759b45495dc359a3fb9b8254ca19e12585c71b2571bf892c55c0

See more details on using hashes here.

File details

Details for the file xarray_compare-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: xarray_compare-0.2.0-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

Hashes for xarray_compare-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b1775cb2f399479b4ee0cab53e258b00d258e9a3c93c7778d4f073e6beb3225
MD5 efe1e1c09ebc8c42e2fda99960018584
BLAKE2b-256 cb2928e5fd570a670d1d113fcb3e835e7ee9f29a9c99587f8a8213226970665e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page