import re


def rename_abs_columns_by_wavelength(df):
    """Tidy absorbance values.
    
    Creates new columns "Abs {wavelength}" from wavelength values in previous "# (nm)" columns,
    and populates them with corresponding "# (Abs)" values as floats.
    
    Deletes "# (nm)" and "# (Abs)" columns.
    
    If passed an empty DataFrame, returns None
    """
    
    if len(df) == 0:
        return
    
    # re.escape allows literal treatment of the string; Python tries to treat it as regex otherwise
    nm_cols = df.columns[df.columns.str.contains(re.escape("(nm)"))]
    abs_col_names = []

    for i, current_row in df.iterrows():
        for nm_col in nm_cols:
            # ensure we're handling the corresponding Abs column 
            number = nm_col.split(" ")[0]
            abs_col = f"{number} (Abs)" 
            abs_col_names.append(abs_col)
        
            current_nm_value = int(current_row[nm_col])
            current_abs_value = current_row[abs_col]
        
            df.loc[i, f"Abs {current_nm_value}"] = current_abs_value

    # nm_cols and abs_col_names are different types requiring separate drops
    df = df.drop(axis=1, columns=nm_cols).drop(axis=1, columns=abs_col_names)
    
    return df