pvt1.columns = ['color'] + [('line_' + str(c)) for c in pvt1.columns[1:]]
pvt2 = df.pivot(columns='count', index='color', values='value').reset_index(
    ).fillna('')
pvt2.columns = ['color'] + [('line_' + str(c) + '_value') for c in pvt2.
    columns[1:]]
pvtdf = pd.merge(pvt1, pvt2, on=['color'])
pvtdf = pvtdf[[c for c in sorted(pvtdf.columns)]]
Pandas — создание нескольких столбцов, подобных pd.get_dummies