df1 = df[(df.a != -1) & (df.b != -1)]

**Here is what the above code is Doing:**

1. We’re creating a new DataFrame called df1 that contains only the rows where both a and b are not equal to -1.

2. We’re using the & operator to combine two Boolean conditions.

3. The first condition is df.a != -1. This returns a Boolean Series that is True when the value of a is not equal to -1 and False otherwise.

4. The second condition is df.b != -1. This returns a Boolean Series that is True when the value of b is not equal to -1 and False otherwise.

5. The & operator takes two Boolean Series and returns a new Boolean Series that is True when both series contain a True value and False otherwise.

6. When we pass this Boolean Series to the [] operator, it returns all of the rows where the Boolean Series is True.