constructed a dataframe by concatenating several dataframes with the keys [a,b,c] as Index
+-------+----------+----------+
| Index | IndexPos | SomeData |
+-------+----------+----------+
| a | 1 | some1 |
| | 2 | some2 |
| | 3 | some3 |
| b | 1 | some1 |
| | 2 | some2 |
| | 3 | some3 |
| c | 1 | some1 |
| | 2 | some2 |
| | 3 | some3 |
+-------+----------+----------+
and now want slice it down to the last 2 elements like:
df.groupby(df.index.levels[0].name).tail(2)
After that I want to recount the remaining elements IndexPos to get this:
+-------+----------+----------+
| Index | IndexPos | SomeData |
+-------+----------+----------+
| a | 1 | some2 |
| | 2 | some3 |
| b | 1 | some2 |
| | 2 | some3 |
| c | 1 | some2 |
| | 2 | some3 |
+-------+----------+----------+
Is there a way to do this, or do I have to slice it before concatenating?