Pandas loc method

Hello, i worked with stack overflow developer survey 2019 datasets. Here i face a interesting problem. Please see the attachment. When i use single condition the sum of python user is 3105. But when i use multiple condition it shows only 102. Why so far difference between this two code? Which is the correct result and why?

You use & which is not a boolean operator in Python (it’s bitwise op). You should use and. I would check the types of both values you pass into .loc[]. Not sure how pandas handles this, so to be sure I would check and.
Edit: I’ve just checked and seems that & is preferred by pandas in such cases. So the above doesn’t apply.

Also, you’re checking if your column contains “Python”, not if it’s equal. In the first case it can be that it considers text like “Python 2.7” or “Python 3.8” to also be part of your sum. In second case you are applying the equality by condition, so it won’t consider them too (because there won’t be such data in your df after this condition).