TheNeuralBit commented on a change in pull request #14850:
URL: https://github.com/apache/beam/pull/14850#discussion_r639242557



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1677,10 +1643,46 @@ def aggregate(self, func, axis=0, *args, **kwargs):
             [self._expr],
             requires_partition_by=partitionings.Singleton()))
     else:
-      # In the general case, compute the aggregation of each column separately,
-      # then recombine.
+      # In the general case, we will compute the aggregation of each column
+      # separately, then recombine.
+
+      # First, handle any kwargs that cause a projection, by eagerly generating
+      # the proxy, and only including the columns that are in the output.
+      PROJECT_KWARGS = ('numeric_only', 'bool_only', 'include', 'exclude')
+      proxy = self._expr.proxy().agg(func, axis, *args, **kwargs)
+
+      if isinstance(proxy, pd.DataFrame):
+        projected = self[list(proxy.columns)]
+      elif isinstance(proxy, pd.Series):
+        projected = self[list(proxy.index)]
+      else:
+        projected = self
+
+      nonnumeric_columns = [name for (name, dtype) in projected.dtypes.items()
+                            if not
+                            pd.core.dtypes.common.is_numeric_dtype(dtype)]
+
+      if _is_numeric(func) and len(nonnumeric_columns):

Review comment:
       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]


Reply via email to