ueshin commented on a change in pull request #34160:
URL: https://github.com/apache/spark/pull/34160#discussion_r720524733
##########
File path: python/pyspark/pandas/groupby.py
##########
@@ -1207,17 +1208,24 @@ def pandas_apply(pdf: pd.DataFrame, *a: Any, **k: Any)
-> Any:
pdf[groupkey_name].rename(psser.name)
for groupkey_name, psser in zip(groupkey_names,
self._groupkeys)
]
+ grouped = pdf.groupby(groupkeys)
if is_series_groupby:
- pser_or_pdf = pdf.groupby(groupkeys)[name].apply(pandas_apply,
*args, **kwargs)
+ pser_or_pdf = grouped[name].apply(pandas_apply, *args,
**kwargs)
else:
- pser_or_pdf = pdf.groupby(groupkeys).apply(pandas_apply,
*args, **kwargs)
+ pser_or_pdf = grouped.apply(pandas_apply, *args, **kwargs)
psser_or_psdf = ps.from_pandas(pser_or_pdf)
if len(pdf) <= limit:
if isinstance(psser_or_psdf, ps.Series) and is_series_groupby:
psser_or_psdf = psser_or_psdf.rename(cast(SeriesGroupBy,
self)._psser.name)
return cast(Union[Series, DataFrame], psser_or_psdf)
+ if len(grouped) <= 1:
Review comment:
Thanks for the suggestion, but for the shortcut path which returns at
line 1221, which means all the data in the DataFrame collected and handled by
pandas properly, so we don't need to show any warnings.
--
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]