def rms ( x ) : try : return ( np . array ( x ) ** 2 ) . mean ( ) ** 0.5 except : x = np . array ( dropna ( x ) ) invN = 1.0 / len ( x ) return ( sum ( invN * ( x_i ** 2 ) for x_i in x ) ) ** .5
how to write code for an rms average equation in python
Root Mean Square
def rms(x):
    """"Root Mean Square"

    Arguments:
        x (seq of float): A sequence of numerical values

    Returns:
        The square root of the average of the squares of the values

        math.sqrt(sum(x_i**2 for x_i in x) / len(x))

        or

        return (np.array(x) ** 2).mean() ** 0.5

    >>> rms([0, 2, 4, 4])
    3.0
    """
    try:
        return (np.array(x) ** 2).mean() ** 0.5
    except:
        x = np.array(dropna(x))
        invN = 1.0 / len(x)
        return (sum(invN * (x_i ** 2) for x_i in x)) ** .5