I have a dataframe called rollTestLogReturnsData which is indexed by date
BBG.KABN.S BBG.TKA.S BBG.CON.S BBG.ISAT.S
date
2015-02-17 -0.005821 -0.016792 -0.016111 0.001028
2015-02-18 0.000588 0.019169 -0.000307 -0.001832
2015-02-19 0.005041 -0.007580 0.004164 0.003923
2015-02-20 -0.004881 0.008011 0.007047 -0.000307
2015-02-23 0.007468 -0.011277 -0.003273 0.004355
I then create another dataframe called rollReturnRandomDf indexed by date which is a random selection of rows from rollTestLogReturnsData. This is constructed using:
rollReturnRandomDf = rollTestLogReturnsData.ix[np.random.choice(rollTestLogReturnsData.index, len(rollTestLogReturnsData.index))]
which can look like:
BBG.KABN.S BBG.TKA.S BBG.CON.S BBG.ISAT.S
date
2015-02-20 -0.004881 0.008011 0.007047 -0.000307
2015-02-20 -0.004881 0.008011 0.007047 -0.000307
2015-02-19 0.005041 -0.007580 0.004164 0.003923
2015-02-17 -0.005821 -0.016792 -0.016111 0.001028
2015-02-20 -0.004881 0.008011 0.007047 -0.000307
Please note that the index date can be the same for multiple rows (in this case 2015-02-20 occurs 3 times). The problems start when I interrogate rollTestLogReturnsData.
Is there a way to reindex the rollTestLogReturnsData dataframe with integers so it would look like:
BBG.KABN.S BBG.TKA.S BBG.CON.S BBG.ISAT.S
Index
0 -0.004881 0.008011 0.007047 -0.000307
1 -0.004881 0.008011 0.007047 -0.000307
2 0.005041 -0.007580 0.004164 0.003923
3 -0.005821 -0.016792 -0.016111 0.001028
4 -0.004881 0.008011 0.007047 -0.000307
I have tried manipulating the above line of code but have failed to come up with a way to do this. What can I try next?