My recipe to help debug
Add df.to_excel("temp.xls")
where needed then launch calc.
LibreOffice / LO / libreoffice Calc tips
https://stackoverflow.com/questions/28353470/how-to-sort-rows-according-to-one-of-the-columns
To filter out empty columns, Data -> Autofilter then select column header and choose order https://askubuntu.com/questions/943662/libreoffice-calc-delete-empty-rows