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/04/25 02:57:50 UTC

[GitHub] [spark] itholic commented on a diff in pull request #36309: [SPARK-39000][PYTHON] Convert bools to ints in basic statistical functions of GroupBy objects

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


##########
python/pyspark/pandas/tests/test_groupby.py:
##########
@@ -1257,7 +1258,34 @@ def _test_stat_func(self, func):
             (pdf.groupby("A"), psdf.groupby("A")),
             (pdf.groupby("A")[["C"]], psdf.groupby("A")[["C"]]),
         ]:
-            self.assert_eq(func(p_groupby_obj).sort_index(), func(ps_groupby_obj).sort_index())
+            self.assert_eq(
+                func(p_groupby_obj).sort_index(),
+                func(ps_groupby_obj).sort_index(),
+                check_exact=check_exact,
+            )
+
+    def test_basic_stat_funcs(self):
+        self._test_stat_func(lambda groupby_obj: groupby_obj.mean(), check_exact=False)
+        self._test_stat_func(lambda groupby_obj: groupby_obj.std(), check_exact=False)

Review Comment:
   Hmm... seems like the `pdf.groupby("A")[["C"]].std()` raises Exception from pandas 1.4.0 as below:
   
   ```python
   >>> pdf = pd.DataFrame(
   ...             {
   ...                 "A": [1, 2, 1, 2],
   ...                 "B": [3.1, 4.1, 4.1, 3.1],
   ...                 "C": ["a", "b", "b", "a"],
   ...                 "D": [True, False, False, True],
   ...             }
   ...         )
   >>> pdf.groupby("A")[["C"]].std()
   Traceback (most recent call last):
   ...
   ValueError: could not convert string to float: 'a'
   ```
   
   Can we fix & separate the test??



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