def n_distinct(x):
    """Return the total number of distinct (i.e. unique) elements in an array.
    
    Example:
        >>> n_distinct(pd.Series([1,1,2,2]))
        2

    """
    return x.nunique()