TheNeuralBit commented on a change in pull request #14140:
URL: https://github.com/apache/beam/pull/14140#discussion_r587665489
##########
File path: sdks/python/apache_beam/dataframe/pandas_doctests_test.py
##########
@@ -411,6 +411,96 @@ def test_indexing_tests(self):
})
self.assertEqual(result.failed, 0)
+ def test_groupby_tests(self):
+ result = doctests.testmod(
+ pd.core.groupby.groupby,
+ use_beam=False,
+ wont_implement_ok={
+ 'pandas.core.groupby.groupby.GroupBy.head': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.tail': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.nth': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.cumcount': ['*'],
+ },
+ not_implemented_ok={
+ 'pandas.core.groupby.groupby.GroupBy.describe': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.ngroup': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.resample': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.sample': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.resample': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.quantile': ['*'],
+ 'pandas.core.groupby.groupby.BaseGroupBy.pipe': ['*'],
+ 'pandas.core.groupby.groupby.GroupBy.nth': [
+ "df.groupby('A', as_index=False).nth(1)",
+ ],
+ },
+ skip={
+ # Uses iloc to mutate a DataFrame
+ 'pandas.core.groupby.groupby.GroupBy.resample': [
+ 'df.iloc[2, 0] = 5',
+ 'df',
+ ],
+ # TODO: Raise wont implement for list passed as a grouping column
+ # Currently raises unhashable type: list
+ 'pandas.core.groupby.groupby.GroupBy.ngroup': [
+ 'df.groupby(["A", [1,1,2,3,2,1]]).ngroup()'
+ ],
+ })
+ self.assertEqual(result.failed, 0)
+
+ result = doctests.testmod(
+ pd.core.groupby.generic,
+ use_beam=False,
+ wont_implement_ok={
+ # Returns an array by default, not a Series. WontImplement
+ # (non-deferred)
+ 'pandas.core.groupby.generic.SeriesGroupBy.unique': ['*'],
+ # TODO: Is take actually deprecated?
+ 'pandas.core.groupby.generic.DataFrameGroupBy.take': ['*'],
+ 'pandas.core.groupby.generic.SeriesGroupBy.take': ['*'],
+ 'pandas.core.groupby.generic.SeriesGroupBy.nsmallest': [
+ "s.nsmallest(3, keep='last')",
Review comment:
1. Correct, except these are generally references to methods and their
docstrings. It's implemented here:
https://github.com/apache/beam/blob/05f520074b3a456f2ecf5df44f1602ca14bcb415/sdks/python/apache_beam/dataframe/doctests.py#L316-L320
2. Yeah I was confused by this too. It looks like some of these docstrings
aren't actually testing the thing they say they do. Presumably due to some
inheritance structure? It may behoove us to help clean up some of these
examples upstream. (e.g. I just sent
https://github.com/pandas-dev/pandas/pull/40207 for groupby.apply)
----------------------------------------------------------------
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:
[email protected]