fixed mistake with groupby loop, dataframe reindexed on slice