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 2021/12/02 06:31:38 UTC

[GitHub] [spark] dchvn commented on a change in pull request #34778: [SPARK-36396][PYTHON][FOLLOWUP] Fix test with extensions dtype when pandas version < 1.2

dchvn commented on a change in pull request #34778:
URL: https://github.com/apache/spark/pull/34778#discussion_r760795723



##########
File path: python/pyspark/pandas/tests/test_dataframe.py
##########
@@ -5870,8 +5870,12 @@ def test_cov(self):
         self.assert_eq(pdf.cov(min_periods=5), psdf.cov(min_periods=5))
 
         # extension dtype
-        numeric_dtypes = ["Int8", "Int16", "Int32", "Int64", "Float32", "Float64", "float"]
-        boolean_dtypes = ["boolean", "bool"]
+        if LooseVersion(pd.__version__) >= LooseVersion("1.2"):

Review comment:
       with pandas < 1.2, `pd.Dataframe.cov` can not work with extension dtype `NAType`, so I just fix the test only
   ```python
   >>> pd.__version__
   '1.0.5'
   >>> pdf = pd.DataFrame([[1,2],[None, 3]], dtype="Int64")
   >>> pdf
         0  1
   0     1  2
   1  <NA>  3
   >>> pdf.cov()
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/u02/venv/python3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 7608, in cov
       baseCov = libalgos.nancorr(ensure_float64(mat), cov=True, minp=min_periods)
     File "pandas/_libs/algos_common_helper.pxi", line 41, in pandas._libs.algos.ensure_float64
   TypeError: float() argument must be a string or a number, not 'NAType'
   ```




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