(a, patterns, case_sensitive, match_beginning,
                     map_values=None)
return res
Map values in a using a list of patterns. The patterns are considered in
    order of appearance.

    Args:
        a (np.array): input array of `dtype` `str`
        patterns (list of str): list of strings
        case_sensitive (bool): case sensitive match
        match_beginning (bool): match only at the beginning of the string
        map_values (list of int): list of len(pattens);
                                  contains return values for each pattern

    Returns:
        np.array of floats representing indices of matched patterns
Map values in a using a list of patterns. The patterns are considered in
    order of appearance.
Map values in a using a list of patterns . The patterns are considered in order of appearance .
def map_by_substring(a, patterns, case_sensitive, match_beginning,
                     map_values=None):
    """
    Map values in a using a list of patterns. The patterns are considered in
    order of appearance.

    Args:
        a (np.array): input array of `dtype` `str`
        patterns (list of str): list of strings
        case_sensitive (bool): case sensitive match
        match_beginning (bool): match only at the beginning of the string
        map_values (list of int): list of len(pattens);
                                  contains return values for each pattern

    Returns:
        np.array of floats representing indices of matched patterns
    """
    if map_values is None:
        map_values = np.arange(len(patterns))
    else:
        map_values = np.array(map_values, dtype=int)
    res = np.full(len(a), np.nan)
    if not case_sensitive:
        a = np.char.lower(a)
        patterns = (pattern.lower() for pattern in patterns)
    for val_idx, pattern in reversed(list(enumerate(patterns))):
        indices = np.char.find(a, pattern)
        matches = indices == 0 if match_beginning else indices != -1
        res[matches] = map_values[val_idx]
    return res
def map_by_substring ( a , patterns , case_sensitive , match_beginning , map_values = None ) : if map_values is None : map_values = np . arange ( len ( patterns ) ) else : map_values = np . array ( map_values , dtype = int ) res = np . full ( len ( a ) , np . nan ) if not case_sensitive : a = np . char . lower ( a ) patterns = ( pattern . lower ( ) for pattern in patterns ) for val_idx , pattern in reversed ( list ( enumerate ( patterns ) ) ) : indices = np . char . find ( a , pattern ) matches = indices == 0 if match_beginning else indices != - 1 res [ matches ] = map_values [ val_idx ] return res