{ } Raw JSON

bundles / numpy 2.4.4 / numpy / char / compare_chararrays

built-in

numpy.char:compare_chararrays

Signature

built-in compare_chararrays ( a1 a2 cmp rstrip )

Summary

Performs element-wise comparison of two string arrays using the comparison operator specified by cmp.

Parameters

a1, a2 : array_like

Arrays to be compared.

cmp : {"<", "<=", "==", ">=", ">", "!="}

Type of comparison.

rstrip : bool

If True, the spaces at the end of strings are removed before the comparison.

Returns

out : ndarray

The output array of type numpy.bool with the same shape as a1 and a2.

Raises

: ValueError

If cmp is not valid.

: TypeError

If at least one of a1 or a2 is a non-string array

Examples

import numpy as np
a = np.array(["a", "b", "cde"])
b = np.array(["a", "a", "dec"])
np.char.compare_chararrays(a, b, ">", True)

Aliases

  • numpy.char.compare_chararrays