eccpy/tools.py
def normalise_between_2_values(arraylike, min_value, max_value, invert=False):
    """Normalises an array of data between two desired values.

    Any values below min_value will be converted to 0.
    Any values above max_value will be converted to 1.
    Optionally, the normalised array can be inverted, so that the original highest
    values are 0, and the original lowest values are now 1.

    Parameters
    ----------
    arraylike : np.ndarray
        Arraylike original data (numpy array or pandas Series)
    min_value : float
        Desired minimum value for normalisation
    max_value : float
        Desired max value for normalisation
    invert : bool
        If True, normalised data will be inverted (former highest value = 0)

    Returns
    -------
    normalised : np.ndarray
        Normalised array of data

    Usage
    -----
    from eccpy.tools import normalise_between_2_values
    # for array
    orig_array = np.array(range(0, 15))
    norm_array = normalise_between_2_values(orig_array, 3, 10)
    # for pandas Dataframe
    df["norm_data"] = normalise_between_2_values(df["orig_data"], 3, 10)
    """
    # normalise array between min and max values
    normalised = (arraylike - min_value)/(max_value - min_value)
    # replace anything above 1 with 1
    normalised[normalised > 1] = 1
    # replace anything below 0 with 0
    normalised[normalised < 0] = 0
    # if desired, invert the normalised values
    if invert:
        normalised = abs(normalised - 1)
    return normalised
Normalises an array of data between two desired values.

    Any values below min_value will be converted to 0.
    Any values above max_value will be converted to 1.
    Optionally, the normalised array can be inverted, so that the original highest
    values are 0, and the original lowest values are now 1.

    Parameters
    ----------
    arraylike : np.ndarray
        Arraylike original data (numpy array or pandas Series)
    min_value : float
        Desired minimum value for normalisation
    max_value : float
        Desired max value for normalisation
    invert : bool
        If True, normalised data will be inverted (former highest value = 0)

    Returns
    -------
    normalised : np.ndarray
        Normalised array of data

    Usage
    -----
    from eccpy.tools import normalise_between_2_values
    # for array
    orig_array = np.array(range(0, 15))
    norm_array = normalise_between_2_values(orig_array, 3, 10)
    # for pandas Dataframe
    df["norm_data"] = normalise_between_2_values(df["orig_data"], 3, 10)
    
Normalises an array of data between two desired values.
Any values below min_value will be converted to 0.
Any values above max_value will be converted to 1.
Optionally, the normalised array can be inverted, so that the original highest
values are 0, and the original lowest values are now 1.

Parameters

arraylike : np.ndarray
Arraylike original data (numpy array or pandas Series)
min_value : float
Desired minimum value for normalisation
max_value : float
Desired max value for normalisation
invert : bool
If True, normalised data will be inverted (former highest value = 0)

Returns

normalised : np.ndarray
Normalised array of data

Usage


Normalises an array of data between two desired values . Any values below min_value will be converted to 0 . Any values above max_value will be converted to 1 . Optionally the normalised array can be inverted so that the original highest values are 0 and the original lowest values are now 1 . Parameters arraylike : np . ndarray Arraylike original data ( numpy array or pandas Series ) min_value : float Desired minimum value for normalisation max_value : float Desired max value for normalisation invert : bool If True normalised data will be inverted ( former highest value = 0 ) Returns normalised : np . ndarray Normalised array of data Usage
def normalise_between_2_values(arraylike, min_value, max_value, invert=False):
    normalised = (arraylike - min_value)/(max_value - min_value)
    normalised[normalised > 1] = 1
    normalised[normalised < 0] = 0
    if invert:
        normalised = abs(normalised - 1)
    return normalised
def normalise_between_2_values ( arraylike , min_value , max_value , invert = False ) : normalised = ( arraylike - min_value ) / ( max_value - min_value ) normalised [ normalised > 1 ] = 1 normalised [ normalised < 0 ] = 0 if invert : normalised = abs ( normalised - 1 ) return normalised
Normalises an array of data between two desired values.
Normalises an array of data between two desired values .
"""Normalises an array of data between two desired values.

    Any values below min_value will be converted to 0.
    Any values above max_value will be converted to 1.
    Optionally, the normalised array can be inverted, so that the original highest
    values are 0, and the original lowest values are now 1.

    Parameters
    ----------
    arraylike : np.ndarray
        Arraylike original data (numpy array or pandas Series)
    min_value : float
        Desired minimum value for normalisation
    max_value : float
        Desired max value for normalisation
    invert : bool
        If True, normalised data will be inverted (former highest value = 0)

    Returns
    -------
    normalised : np.ndarray
        Normalised array of data

    Usage
    -----
    from eccpy.tools import normalise_between_2_values
    # for array
    orig_array = np.array(range(0, 15))
    norm_array = normalise_between_2_values(orig_array, 3, 10)
    # for pandas Dataframe
    df["norm_data"] = normalise_between_2_values(df["orig_data"], 3, 10)
    """ # normalise array between min and max values # replace anything above 1 with 1 # replace anything below 0 with 0 # if desired, invert the normalised values
arraylike
min_value
max_value
invert