I have some data like this:
import pandas as pd
df = pd.DataFrame(index = range(1,13), columns=[\'school\', \'year\', \'metric\', \'values\'], )
df[\'school\'] =
you can use pivot_table():
In [23]: df2 = (df.pivot_table(index=['school', 'year'], columns='metric',
....: values='values')
....: .reset_index()
....: )
In [24]:
In [24]: df2
Out[24]:
metric school year admitsize avgfinaid tuition
0 id1 2015 2 3 1
1 id1 2016 5 6 4
2 id2 2015 8 9 7
3 id2 2016 11 12 10