(prices, use_log=True)
return pd.DataFrame(values[1:, :], index=prices.index[1:], columns=prices.columns)
Convert prices to returns.

    Parameters
    ----------
    prices : pd.DataFrame
        Rows represent different time points and the columns represent different assets. Note that the columns
        can also be a ``pd.MultiIndex``.

    use_log : bool
        If True, then logarithmic returns are used (natural logarithm). If False, then simple returns.

    Returns
    -------
    returns : pd.DataFrame
        Returns per asset per period. The first period is deleted.
Convert prices to returns.
Convert prices to returns .
def prices_to_returns(prices, use_log=True):
    """Convert prices to returns.

    Parameters
    ----------
    prices : pd.DataFrame
        Rows represent different time points and the columns represent different assets. Note that the columns
        can also be a ``pd.MultiIndex``.

    use_log : bool
        If True, then logarithmic returns are used (natural logarithm). If False, then simple returns.

    Returns
    -------
    returns : pd.DataFrame
        Returns per asset per period. The first period is deleted.

    """
    # checks

    if use_log:
        values = np.log(prices.values) - np.log(prices.shift(1).values)
    else:
        values = (prices.values - prices.shift(1).values) / prices.shift(1).values

    return pd.DataFrame(values[1:, :], index=prices.index[1:], columns=prices.columns)
def prices_to_returns ( prices , use_log = True ) : # checks if use_log : values = np . log ( prices . values ) - np . log ( prices . shift ( 1 ) . values ) else : values = ( prices . values - prices . shift ( 1 ) . values ) / prices . shift ( 1 ) . values return pd . DataFrame ( values [ 1 : , : ] , index = prices . index [ 1 : ] , columns = prices . columns )