ueshin commented on a change in pull request #34052:
URL: https://github.com/apache/spark/pull/34052#discussion_r712562041
##########
File path: python/pyspark/pandas/tests/test_series.py
##########
@@ -1652,6 +1652,40 @@ def test_pop(self):
with self.assertRaisesRegex(KeyError, msg):
psser.pop(("lama", "speed", "x"))
+ pser = pd.Series(["a", "b", "c", "a"], dtype="category")
+ psser = ps.from_pandas(pser)
+
+ if LooseVersion(pd.__version__) >= LooseVersion("1.3.0"):
+ self.assert_eq(psser.pop(0), pser.pop(0))
+ self.assert_eq(psser, pser)
+
+ self.assert_eq(psser.pop(3), pser.pop(3))
+ self.assert_eq(psser, pser)
+ else:
+ # Before pandas 1.3.0, `pop` modifies the dtype of categorical
series wrongly.
+ self.assert_eq(psser.pop(0), pser.pop(0))
+ self.assert_eq(
+ psser,
+ pd.Series(
+ pd.Categorical(["b", "c", "a"], categories=["a", "b",
"c"]), index=[1, 2, 3]
+ ),
+ )
+
+ if LooseVersion(pd.__version__) >= LooseVersion("1.1.0"):
Review comment:
Then we don't need to split here.
```py
self.assert_eq(psser.pop(3), "a")
```
##########
File path: python/pyspark/pandas/tests/test_series.py
##########
@@ -1652,6 +1652,40 @@ def test_pop(self):
with self.assertRaisesRegex(KeyError, msg):
psser.pop(("lama", "speed", "x"))
+ pser = pd.Series(["a", "b", "c", "a"], dtype="category")
+ psser = ps.from_pandas(pser)
+
+ if LooseVersion(pd.__version__) >= LooseVersion("1.3.0"):
+ self.assert_eq(psser.pop(0), pser.pop(0))
+ self.assert_eq(psser, pser)
+
+ self.assert_eq(psser.pop(3), pser.pop(3))
+ self.assert_eq(psser, pser)
+ else:
+ # Before pandas 1.3.0, `pop` modifies the dtype of categorical
series wrongly.
+ self.assert_eq(psser.pop(0), pser.pop(0))
Review comment:
I guess we can use a literal as an expected value instead of
`pser.pop(0)`.
```py
self.assert_eq(psser.pop(0), "a")
```
--
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]