itholic commented on a change in pull request #33757:
URL: https://github.com/apache/spark/pull/33757#discussion_r690857061
##########
File path: python/pyspark/pandas/tests/test_categorical.py
##########
@@ -243,18 +243,16 @@ def test_astype(self):
self.assert_eq(kcser.astype("category"), pcser.astype("category"))
+ # CategoricalDtype is not updated if the dtype is same from pandas 1.3.
if LooseVersion(pd.__version__) >= LooseVersion("1.3"):
- # TODO(SPARK-36367): Fix the behavior to follow pandas >= 1.3
- pass
- elif LooseVersion(pd.__version__) >= LooseVersion("1.2"):
self.assert_eq(
kcser.astype(CategoricalDtype(["b", "c", "a"])),
pcser.astype(CategoricalDtype(["b", "c", "a"])),
)
else:
self.assert_eq(
kcser.astype(CategoricalDtype(["b", "c", "a"])),
- pser.astype(CategoricalDtype(["b", "c", "a"])),
+ kcser,
Review comment:
Yes, because `kcser` is pandas-on-Spark Series, which always follows
latest pandas(1.3).
Latest pandas doesn't update the `dtype` after `astype`, if the unique
values of target `dtype` are the same as original unique values as described in
the PR description.
```python
>>> pcat1 = pser.astype(CategoricalDtype(["b", "c", "a"]))
>>> pcat2 = pser.astype(CategoricalDtype(["a", "b", "c"]))
>>> pcat1.dtype == pcat2.dtype
True
```
--
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]