itholic commented on code in PR #37235:
URL: https://github.com/apache/spark/pull/37235#discussion_r925405082
##########
python/pyspark/pandas/tests/indexes/test_base.py:
##########
@@ -2511,6 +2511,36 @@ def test_drop_level(self):
):
psmidx.droplevel(-3)
+ def test_where_putmask(self):
+ pidx = pd.Index([1, 2, 3, 4])
+ psidx = ps.from_pandas(pidx)
+
+ # where and putmask with default inserted value np.nan
+ self.assert_eq(
+ pidx.where(pidx > 2),
+ psidx.where(psidx > 2)
+ )
+ self.assert_eq(
+ pidx.putmask(pidx > 2, 99),
+ psidx.putmask(psidx > 2, 99)
+ )
+
+ # where and putmask with isin func
+ self.assert_eq(
+ pidx.where(pidx.isin([1, 2])),
+ psidx.where(psidx.isin([1, 2]))
+ )
+ self.assert_eq(
+ pidx.putmask(pidx.isin([1, 2]), 99),
+ psidx.putmask(psidx.isin([1, 2]), 99)
+ )
Review Comment:
Shall we have a bit more test for complex case ??
e.g.
```python
(pidx + 1).putmask((pidx + 1).isin([1, 2]), 99),
(psidx + 1).putmask((psidx + 1).isin([1, 2]), 99)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]