KOTA ITO

Generation

generate functionSat, 10 Dec 2022

データフレームの特定の列に出現するユニークな要素のランキングを出す。

def get_top_n_rank(df, col, n=5): return df[col].value_counts().iloc[:n]

Questions about programming?Chat with your personal AI assistant