def frequency_encoder (df, categorical_name, drop=False, new_col_name=None):
    """
    Pandas dataframe series frequency encoder in a new column.

    Parameters
    ----------
    df : Pandas.Dataframe()
        Dataset.
    categorical_name : string
        Name of the column to encoder.
    drop : boolean
        To drop column after encoding or not.
    new_col_name : string
        Name of the new column.

    Returns
    -------
    Pandas.DataFrame()
        Pandas dataframe with a frequency encoded column 

    """
    if new_col_name is None:
        new_col_name = 'freq_'+categorical_name
    g = df[categorical_name].value_counts()/df.shape[0]
    for i in g.index:
        df.loc[df[categorical_name] == i, new_col_name] = g.loc[g.index==i].values[0]
    if drop:
        df = df.drop(categorical_name, axis=1)
    return df