Instead of calling to the database for every floor, only an initial call is needed. Moreover, DataFrame accesses are also decreased; instead of calling .groupby() on an entire DataFrame for every location, it is only called on the particular series for that floor.
Instead of calling to the database for every floor, only an initial call is needed. Moreover, DataFrame accesses are also decreased; instead of calling .groupby() on an entire DataFrame for every location, it is only called on the particular series for that floor.
Execution time decreased from ~6s to ~1s.