itholic commented on code in PR #42994:
URL: https://github.com/apache/spark/pull/42994#discussion_r1331072003


##########
python/pyspark/pandas/groupby.py:
##########
@@ -1155,14 +1152,32 @@ def nth(self, n: int) -> FrameLike:
         else:
             sdf = sdf.select(*groupkey_names).distinct()
 
-        internal = internal.copy(
+        agg_columns = []
+        if not self._agg_columns_selected:

Review Comment:
   `groupkeys` is going to be a data column instead of index when it's not 
included by `agg_columns_selected`. And index should be kept without updating 
from Pandas 2.0.0 for `nth`. Therefore, we should include the `groupkeys` into 
agg_columns to make it as a data column and create a new `InternalFrame` 
manually.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to