xinrong-databricks commented on a change in pull request #33757:
URL: https://github.com/apache/spark/pull/33757#discussion_r690605149



##########
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"])),

Review comment:
       Shall we rename `kcser` to `pscser`? It's fine to do it in a separate PR 
though.

##########
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:
       So when `LooseVersion(pd.__version__) < LooseVersion("1.3")`, `kcser` is 
not updated?

##########
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"])),

Review comment:
       Shall we rename `kcser` to `pscser` in this function? It's fine to do it 
in a separate PR though.




-- 
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]

Reply via email to