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


##########
python/pyspark/pandas/frame.py:
##########
@@ -8689,7 +8702,13 @@ def sample(
         sdf = self._internal.resolved_copy.spark_frame.sample(
             withReplacement=replace, fraction=frac, seed=random_state
         )
-        return DataFrame(self._internal.with_new_sdf(sdf))
+        if ignore_index:
+            spark_index_names = [
+                SPARK_INDEX_NAME_FORMAT(i) for i in 
range(self._internal.index_level)
+            ]
+            return DataFrame(sdf.drop(*spark_index_names))

Review Comment:
   ```suggestion
               return 
DataFrame(sdf.drop(*self._internal.index_spark_column_names))
   ```
   
   I think maybe `spark_index_names` is already in 
`self._internal.index_spark_column_names` ?



##########
python/pyspark/pandas/frame.py:
##########
@@ -8659,6 +8664,14 @@ def sample(
         falcon         2          2                 10
         fish           0          0                  8
 
+        A random 50% sample of the ``DataFrame``, while ignoring the index.
+
+        >>> df.sample(frac=0.5, random_state=1, ignore_index=True)  # doctest: 
+SKIP

Review Comment:
   qq: why do we skip this ?



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