<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json(df, values):
 """Format output for the json response."""

        records = []
        if df.empty:
            return {"data": []}

        sum_ = float(np.sum([df[c].iloc[0] for c in values]))
        for c in values:
            records.append({
                "label": values[c],
                "value": "%.2f"%np.around(df[c].iloc[0] / sum_, decimals=2)
                })
        return {
            "data" : records
        }