human
Python Pandas Pivot Table
assistant
Here is some code to produce a pivot table as dataframe using column 'Y' in datafram `df` to form the axes of the resulting dataframe

df.pivot_table('Y', rows='X', cols='X2')

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.