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 2019/04/05 22:38:43 UTC

[GitHub] [spark] BryanCutler commented on a change in pull request #24306: [SPARK-27387][PYTHON][TESTS] Replace sqlutils.assertPandasEqual with Pandas assert_frame_equals

BryanCutler commented on a change in pull request #24306: [SPARK-27387][PYTHON][TESTS] Replace sqlutils.assertPandasEqual with Pandas assert_frame_equals 
URL: https://github.com/apache/spark/pull/24306#discussion_r272762923
 
 

 ##########
 File path: python/pyspark/sql/tests/test_pandas_udf_grouped_map.py
 ##########
 @@ -29,6 +29,25 @@
     pandas_requirement_message, pyarrow_requirement_message
 from pyspark.testing.utils import QuietTest
 
+if have_pandas:
+    import pandas as pd
+    from pandas.util.testing import assert_frame_equal as pd_assert_frame_equal
+
+if have_pyarrow:
+    import pyarrow as pa
+
+
+def assert_frame_equal(left, right):
+    """
+    Wrap Pandas function because pd.DataFrame.assign will infer mixed types (unicode/str)
+    w/ Python 2, so need to set check_column_type=False
+    """
+    import sys
+    if sys.version < '3':
+        pd_assert_frame_equal(left, right, check_column_type=False)
 
 Review comment:
   This was the only surprise, and it's because calling `DataFrame.apply` with kwargs infers the column names as str for Python 2, and causes DataFrame.columns.inferred_type to be 'mixed' and the assert to fail

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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