v = df.values
s = pd.Series(v[:, 1:].ravel(), v[:, (0)].repeat(3))
s.groupby(level=0).value_counts().unstack(fill_value=0)
turn rows values to columns , and count repetitions for all possible values mysql