You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/27 22:13:04 UTC

[GitHub] [spark] xinrong-meng commented on a diff in pull request #38015: [SPARK-40577][PS] Fix `CategoricalIndex.append` to match pandas 1.5.0

xinrong-meng commented on code in PR #38015:
URL: https://github.com/apache/spark/pull/38015#discussion_r981758420


##########
python/pyspark/pandas/indexes/base.py:
##########
@@ -1907,6 +1908,9 @@ def append(self, other: "Index") -> "Index":
             )
 
         index_fields = self._index_fields_for_union_like(other, func_name="append")
+        # Since pandas 1.5.0, the order of category matters.
+        if isinstance(other, CategoricalIndex):
+            other = other.reorder_categories(self.categories.to_list())

Review Comment:
   We may also have a separate `append` for CategoricalIndex to maintain clearer abstraction since we only make `MultiIndex` an exception (allow different behaviors for MultiIndex) in this file.
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org