Your original frame
In [19]: df2
Out[19]:
var1 var2 var3 var4 var5 var6
x_cor y_cor date
928 310 2006257 133 14987 7045 18 240 171
2006273 136 0 7327 30 253 161
2006289 125 0 -239 83 217 168
2006305 95 14604 6786 13 215 57
2006321 84 0 4548 13 133 88
reset_index and set_index are invertible to the original frame
In [20]: df2.reset_index()
Out[20]:
x_cor y_cor date var1 var2 var3 var4 var5 var6
0 928 310 2006257 133 14987 7045 18 240 171
1 928 310 2006273 136 0 7327 30 253 161
2 928 310 2006289 125 0 -239 83 217 168
3 928 310 2006305 95 14604 6786 13 215 57
4 928 310 2006321 84 0 4548 13 133 88
In [21]: df2.reset_index().set_index(['x_cor','y_cor','date'])
Out[21]:
var1 var2 var3 var4 var5 var6
x_cor y_cor date
928 310 2006257 133 14987 7045 18 240 171
2006273 136 0 7327 30 253 161
2006289 125 0 -239 83 217 168
2006305 95 14604 6786 13 215 57
2006321 84 0 4548 13 133 88
To number a column
In [23]: df2['range'] = range(len(df2))
In [24]: df2
Out[24]:
var1 var2 var3 var4 var5 var6 range
x_cor y_cor date
928 310 2006257 133 14987 7045 18 240 171 0
2006273 136 0 7327 30 253 161 1
2006289 125 0 -239 83 217 168 2
2006305 95 14604 6786 13 215 57 3
2006321 84 0 4548 13 133 88 4
You need to store the multi-index frame with the index set (otherwise its just a regular index frame).
Your reindexing step doesn't do anything aas you are reindexing by strings, not numbers (e.g. '1','2' is NOT the same as 1,2)
Is your data REALLY large? Why are you not just reading the frame in from the store, modifying in memory, then writing it back (to the original, or a new location).
The strategy you are talking about which essentially creates an indexed column store only makes sense if you have LOTS of data.