[GitHub] [spark] itholic commented on a diff in pull request #38016: [SPARK-40578][PS] Fix `IndexesTest.test_to_frame` when pandas 1.5.0

2022-09-27 Thread GitBox


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



[GitHub] [spark] itholic commented on a diff in pull request #38016: [SPARK-40578][PS] Fix `IndexesTest.test_to_frame` when pandas 1.5.0

2022-09-27 Thread GitBox


itholic commented on code in PR #38016:
URL: https://github.com/apache/spark/pull/38016#discussion_r980976721


##
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)
+#   b
+# 0 404
+# 1 515
+# 3 636
+# 5 353
+# 6 262
+# 8 181
+# 9 090
+#   090
+#   090
+#
+# pandas API on Spark doesn't support mixed type for Index,

Review Comment:
   Could you refer to 
https://github.com/apache/spark/pull/38016#discussion_r980971632 ?
   
   Just refine the comment, so please let me know if there is anything doesn't 
make sense!



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



[GitHub] [spark] itholic commented on a diff in pull request #38016: [SPARK-40578][PS] Fix `IndexesTest.test_to_frame` when pandas 1.5.0

2022-09-27 Thread GitBox


itholic commented on code in PR #38016:
URL: https://github.com/apache/spark/pull/38016#discussion_r980972119


##
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:
   Let me fix the comment to more explicitly.



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



[GitHub] [spark] itholic commented on a diff in pull request #38016: [SPARK-40578][PS] Fix `IndexesTest.test_to_frame` when pandas 1.5.0

2022-09-27 Thread GitBox


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