, , Question/Opinion. , set_index unstack, . . pivot, pivot fill_value, dtype
df.set_index(['A', 'B']).C.unstack(fill_value=0)
B Agree Disagree Strongly Agree Strongly Disagree
A
I am motivated 4 6 5 0
I am open-minded 4 4 0 3
'B' pd.Categorical,
df.B = pd.Categorical(
df.B, ['Strongly Disagree', 'Disagree', 'Agree', 'Strongly Agree'], True)
df.set_index(['A', 'B']).C.unstack(fill_value=0)
B Strongly Disagree Disagree Agree Strongly Agree
A
I am motivated 0 6 4 5
I am open-minded 3 4 4 0