human
Complete the below
def exception_to_nan(func):

    ''''Decorate function to return nan if it raises an exception'
    '''

Give me a the Python code you requested?
assistant
#Here is the Python code you requested.
    def wrap(*a, **kw):
        try:
            return func(*a, **kw)
        except Exception:
            return np.nan
    return wrap