<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_excess_returns(returns, rf, nperiods=None):
 """ Given a series of returns, it will return the excess returns over rf. Args: * returns (Series, DataFrame):
 Returns * rf (float, Series):
 `Risk-Free rate(s) <https://www.investopedia.com/terms/r/risk-freerate.asp>`_ expressed in annualized term or return series * nperiods (int):
 Optional. If provided, will convert rf to different frequency using deannualize only if rf is a float Returns: * excess_returns (Series, DataFrame):
 Returns - rf """

    if type(rf) is float and nperiods is not None:
        _rf = deannualize(rf, nperiods)
    else:
        _rf = rf

    return returns - _rf