def update_hypnogram_cycles(hypno, cycles):
    """
    Add cycle identifiers to hypnogram based on cycle detections

    Parameters
    ----------
    hypno : pd.DataFrame
        Hypnogram dataframe obtained through load_hypno().
    cycles : pd.DataFrame
        Tabulated estimates for onsets, offsets and durations of detected cycles.

    Returns
    -------
    hypno : pd.DataFrame
        Hypnogram dataframe with updated cycle metadata

    """
    # Iterate over each cycle
    for k, cycle in cycles.iterrows():

        # Add onset, offset, mode of offset and durations to hypnogram
        start = cycle["Onset_idx"]
        end = cycle["Offset_idx"]
        hypno.loc[start:end, "Cycle_Num"] = cycle["Cycle"]
        hypno.loc[start:end, "Cycle_Duration"] = cycle["Duration"]
        hypno.loc[start:end, "Cycle_Offset_Mode"] = cycle["Offset_Mode"]

    return hypno