def compute_ema(df, column_source, column_target_ema, time_periods):
    """
    Compute Exponential Moving Average (EMA).

    :param df: dataframe (sorted in ascending time order)
    :param column_source: name of source column in dataframe with values to compute EMA (e.g. close price)
    :param column_target_ema: prefix of target column in dataframe for EMA results
    :param time_periods: list of time periods (number of days for EMA)
    :return: modified dataframe
    """
    # compute EMA for each time period and add results back to dataframe
    for time_period in time_periods:
        key_ema = column_target_ema + "-{:d}".format(time_period)
        ema_series = df[column_source].ewm(span=time_period, adjust=False).mean()
        df[key_ema] = ema_series

    return df