def select_topn(df, top_n=25):
    """ Select top-n keywords for each ranking and value_normalized """
    assert df.columns.str.contains("ranking").any(), "select_topn failed. Missing 'ranking' column."
    
    # top-n by ranking
    topn_idx = df.groupby("ranking").value_normalized.nlargest(top_n).droplevel(0).index
    
    return df.loc[topn_idx, : ]