consider this sample data:
import pandas as pd
import numpy as np
thisDict = {0: '20141216',
1: '20150115',
2: '20150212',
3: '20150316',
4: '20150415',
5: '20150514',
6: '20150615',
7: '20150716',
8: '20150814',
9: '20150915'}
pd.DataFrame.from_dict(thisDict, orient = 'index')
I want basically to turn this into a new dataframe with n columns, where for each row we have the last n values. Consider the data above, for n = 3, it would be:
pd.DataFrame.from_dict({0: [np.nan,np.nan ,np.nan] ,
1: ['20141216',np.nan,np.nan],
2: ['20141216','20150115', np.nan],
3: ['20150316','20150115','20150212'],
...
},orient = 'index')