import re


def datapoints2pandas(s, encode):
    """Transform datapoints to Pandas datapoints
    Examples:
    {column_name} -> df[column_name]
    {column_name} -> encoded(df[column_name]) where column_name is in encoding definitions
    """
    nonzero_col = []
    res = s
    for item in re.findall(r'{(.*?)}', res):
        if item[1:-1] in encode.keys():
            res = res.replace("{"+item+"}", '('+ encode[item[1:-1]] + "(df["+item+"]))")
        else:
            res = res.replace("{"+item+"}", "df["+item+"]")
        nonzero_col.append("df["+item+"]")
    return res, nonzero_col