<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def woe(df, feature_name, target_name):
 """Calculate weight of evidence. Parameters df: Dataframe feature_name: str Column name to encode. target_name: str Target column name. Returns ------- Series """


    def group_woe(group):
        event = float(group.sum())
        non_event = group.shape[0] - event

        rel_event = event / event_total
        rel_non_event = non_event / non_event_total

        return np.log(rel_non_event / rel_event) * 100

    if df[target_name].nunique() > 2:
        raise ValueError('Target column should be binary (1/0).')

    event_total = float(df[df[target_name] == 1.0].shape[0])
    non_event_total = float(df.shape[0] - event_total)

    woe_vals = df.groupby(feature_name)[target_name].transform(group_woe)
    return woe_vals