ueshin commented on a change in pull request #33646:
URL: https://github.com/apache/spark/pull/33646#discussion_r685436498



##########
File path: python/pyspark/pandas/window.py
##########
@@ -706,10 +706,16 @@ def _apply_as_series_or_frame(self, func: 
Callable[[Column], Column]) -> FrameLi
         if groupby._agg_columns_selected:
             agg_columns = groupby._agg_columns
         else:
+            # pandas doesn't keep the groupkey as a column from 1.3 for 
DataFrameGroupBy
+            if isinstance(groupby, DataFrameGroupBy):
+                for groupkey in groupby._groupkeys:  # type: ignore
+                    groupby._column_labels_to_exclude.add(  # type: ignore

Review comment:
       Shall we not update `groupby._column_labels_to_exclude` directly?
   
   ```py
   column_labels_to_exclude = groupby._column_labels_to_exclude.copy()
   if isinstance(groupby, DataFrameGroupBy):
       for ...
           column_labels_to_exclude.add( ... )
   agg_columns = [ ... if label not in column_labels_to_exclude]
   ```




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