gaogaotiantian commented on code in PR #54162:
URL: https://github.com/apache/spark/pull/54162#discussion_r2771831034


##########
python/pyspark/pandas/tests/groupby/test_stat.py:
##########
@@ -35,11 +39,23 @@ def _test_stat_func(self, func, check_exact=True):
             # Against SeriesGroupBy
             (pdf.groupby("A")["B"], psdf.groupby("A")["B"]),
         ]:
-            self.assert_eq(
-                func(p_groupby_obj).sort_index(),
-                func(ps_groupby_obj).sort_index(),
-                check_exact=check_exact,
-            )
+            if expected_error is None:
+                self.assert_eq(
+                    func(p_groupby_obj).sort_index(),
+                    func(ps_groupby_obj).sort_index(),
+                    check_exact=check_exact,
+                )
+            else:
+                error_type, error_message = expected_error
+                self.assertRaisesRegex(error_type, error_message, lambda: 
func(p_groupby_obj))
+                self.assertRaisesRegex(error_type, error_message, lambda: 
func(ps_groupby_obj))
+
+    @property
+    def expected_error_numeric_only(self) -> Optional[Tuple[Type[Exception], 
str]]:

Review Comment:
   I started to think whether we should just have a variable about if we are 
using pandas 3. Then the testing code could just be
   
   ```python
           self._test_stat_func(
               lambda groupby_obj: groupby_obj.max(numeric_only=None),
               expected_error=ValueError if using_pandas3 else None,
           )
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to