def mergeSeriesOnTimestampRange(df_cpu, df_type, fields):
    """
  Upsamples df_type to df_cpu.
  Check unit test for an example
  """
    if df_type.iloc[0].name < df_type.iloc[-1].name:
        raise Exception(
            'Types Dataframe should be sorted descending for utils.mergeSeriesOnTimestampRange'
            )
    import numpy as np
    for f in fields:
        df_cpu[f] = None
    for index, row_type in df_type.iterrows():
        row_i = np.where(df_cpu.Timestamp <= row_type.name)[0]
        for f in fields:
            col_i = df_cpu.columns.get_loc(f)
            df_cpu.iloc[row_i, col_i] = row_type[f]
    for f in fields:
        df_cpu[f] = df_cpu[f].fillna(method='backfill')
    return df_cpu
