#51826_Fixed bug when np.nan is used as index value with .reindex on …

- [x] closes #51826 
- [x] [Tests added and passed]
- [x] All [code checks passed]


In the query method, when `nan` was passed as index value, it triggered the `else` condition, which extended the result, without properly handling `nan`. This fix ensures proper handling of `nan` value right at the beginning of the query, preventing the unexpected behavior during reindexing.