[ 
https://issues.apache.org/jira/browse/BEAM-11542?focusedWorklogId=539703&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-539703
 ]

ASF GitHub Bot logged work on BEAM-11542:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 22/Jan/21 06:03
            Start Date: 22/Jan/21 06:03
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit commented on a change in pull request 
#13637:
URL: https://github.com/apache/beam/pull/13637#discussion_r562292409



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1503,10 +1506,32 @@ def unstack(self, *args, **kwargs):
 
 @populate_not_implemented(pd.core.groupby.generic.DataFrameGroupBy)
 class DeferredGroupBy(frame_base.DeferredFrame):
-  def __init__(self, expr, kwargs):
+  def __init__(self, expr, kwargs,
+               ungrouped: DeferredDataFrameOrSeries, projection=None):
     super(DeferredGroupBy, self).__init__(expr)
+    # This object represents the result of:
+    # ungrouped.groupby(level=list(range(ungrouped.index.nlevels),
+    #                   **kwargs)[projection]
+    self._ungrouped = ungrouped
+    self._projection = projection
     self._kwargs = kwargs
 
+  def __getattr__(self, name):
+    return DeferredGroupBy(expressions.ComputedExpression(
+        'groupby_project',
+        lambda gb: getattr(gb, name), [self._expr],
+        requires_partition_by=partitionings.Nothing(),
+        preserves_partition_by=partitionings.Singleton()),
+                           self._kwargs, self._ungrouped, name)

Review comment:
       Good catch, done.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 539703)
    Time Spent: 2h 10m  (was: 2h)

> Support projecting groupbys
> ---------------------------
>
>                 Key: BEAM-11542
>                 URL: https://issues.apache.org/jira/browse/BEAM-11542
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>            Reporter: Brian Hulette
>            Assignee: Brian Hulette
>            Priority: P2
>              Labels: dataframe-api
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> For example: df.groupby('foo').bar.sum(), or df.groupby('foo')['bar'].sum()



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to