UPDATE!
Just be aware of changing the year to int in both the df and the pivot table (after unstacking). That caused me some trouble :)
Data for the values:
d = {'ID':[1,1,1,2,2,2],'Date':['01-01-2013','01-02-2013','01-03-2013','01-
01-2008','01-02-2008','01-03-2008'],'CUSIP':
['X1','X1','X1','X2','X2','X2'],'X':['bla','bla','bla','bla','bla','bla']}
df = pd.DataFrame(data=d)
I have a dataframe:
Identifier CUSIP X Date
0 1 X1 bla 2013-01-01
1 1 X1 bla 2013-01-02
2 1 X1 bla 2013-01-03
3 2 X2 bla 2008-01-01
4 2 X2 bla 2008-01-02
5 2 X2 bla 2008-01-03
And a pivot table:
2008 2009 2010 2011 2012 2013
CUSIP
X1 1 1 1 1 1 1
X2 2 2 2 2 2 2
And I would like to achieve a layout like:
Identifier CUSIP X Date Values
0 1 X1 bla 2013-01-01 1
1 1 X1 bla 2013-01-02 1
2 1 X1 bla 2013-01-03 1
3 2 X2 bla 2008-01-01 2
4 2 X2 bla 2008-01-02 2
5 2 X2 bla 2008-01-03 2