def nest_for_json(df, groupbycol, nestcol, newcolname):
    """
    df: Dataframe
    groupbycol: The column(s) that will stay as non-lists
    nestcol: The name of the column that will be nested into a list inside a column
    newcolname: The name of the new column
    """
    
    new_df = (df.groupby(groupbycol)
              .apply(lambda x: x[nestcol].values)
              .drop_duplicates()
              .reset_index()
              .rename(columns={0:newcolname}))
    
    new_df[newcolname] = new_df[newcolname].apply(lambda x: list(set(x)))
    
    return new_df