itholic commented on code in PR #38016: URL: https://github.com/apache/spark/pull/38016#discussion_r980971632
########## python/pyspark/pandas/tests/indexes/test_base.py: ########## @@ -203,9 +203,35 @@ def test_to_frame(self): # non-string names self.assert_eq(psidx.to_frame(name=[10, 20]), pidx.to_frame(name=[10, 20])) self.assert_eq(psidx.to_frame(name=("x", 10)), pidx.to_frame(name=("x", 10))) - self.assert_eq( - psidx.to_frame(name=[("x", 10), ("y", 20)]), pidx.to_frame(name=[("x", 10), ("y", 20)]) - ) + if LooseVersion(pd.__version__) < LooseVersion("1.5.0"): + self.assert_eq( + psidx.to_frame(name=[("x", 10), ("y", 20)]), + pidx.to_frame(name=[("x", 10), ("y", 20)]), + ) + else: + # Since pandas 1.5.0, the result is changed as below: + # (x, 10) (y, 20) Review Comment: The exact diff is shown as below: ```python # pandas < 1.5.0 >>> pd.Index([('x', 10), ('y', 20)]).to_frame(name=[("x", 20), ("y", 20)]) x y 20 20 x 10 x 10 y 20 y 20 # pandas >= 1.5.0 >>> pd.Index([('x', 10), ('y', 20)]).to_frame(name=[("x", 20), ("y", 20)]) (x, 20) (y, 20) x 10 x 10 y 20 y 20 ``` The column should be like `Index([('x', 20), ('y', 20)], dtype='object')`, but such as way is not allowed in pandas API on Spark: ```python >>> ps.Index([['x', 20], ['y', 20]]) Traceback (most recent call last): ... pyarrow.lib.ArrowTypeError: Expected bytes, got a 'int' object ``` -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org