I want to select rows in a dataframe based on a given condition. The condition is that all elements in a column With a specified string is selected. This operation is repeated for 4 different strings. The elements in the dataframe is sorted based on year and week, and when I use query on the first string, all values are included in the dataframe relating to that string, but for the remanining 3 strings, Python does not include all values (jumps to the last year, starts in the middle of the first year, etc.) Does anybody know what is going on?