ueshin commented on code in PR #54285:
URL: https://github.com/apache/spark/pull/54285#discussion_r2801569859


##########
python/pyspark/pandas/groupby.py:
##########
@@ -2014,8 +2044,8 @@ def pandas_apply(pdf: pd.DataFrame, *a: Any, **k: Any) -> 
Any:
             sample_limit = limit + 1 if limit else 2
             pdf = psdf.head(sample_limit)._to_internal_pandas()
             groupkeys = [
-                pdf[groupkey_name].rename(psser.name)
-                for groupkey_name, psser in zip(groupkey_names, 
self._groupkeys)
+                pdf[groupkey_name].rename(name)

Review Comment:
   Pre-calculating it is not for this place. It will be used later in the 
internal UDF where `self._groupkeys` shouldn't be captured. As a side effect, 
we can use it there, too.
   
   
https://github.com/apache/spark/blob/f324336cc43396ee589b5a007f9fb703ac4ccef8/python/pyspark/pandas/groupby.py#L2118-L2123



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