I want to move a set of dataframe rows to the beginning
The indexes of the corresponding rows are these ones:
indexes = [2188, 2163, 37, 47, 36, 41, 61, 1009, 40, 39, 123, 121, 2151, 19, 2, 8, 117, 205, 204]
So:
index 204 -> index 0
index 205 -> index 1
.
.
index 2188 -> index 18
At the moment I have this code that allows to move only one row:
def move_row(index):
idx = [index] + [i for i in range(len(df)) if i != index]
return df.iloc[idx].reset_index(drop=True)