BUG: Fix query doesn't support equals or not equals with Python parse…
…r (#40436)

- [X] closes #40436 
- [X] tests added / passed
- [X] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [X] whatsnew entry
