Reset index.
There are use cases for it,but i don't see the need here.
all_data = all_data.reset_index()Try not to use nested functions,it's makes the code harder to read and debug.
There are use cases for it,but i don't see the need here.