forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-38491][PYTHON] Support
ignore_index
of Series.sort_values
### What changes were proposed in this pull request? Support `ignore_index` of `Series.sort_values`, in which the resulting axis will be labeled `0, 1, …, n - 1`. ### Why are the changes needed? To reach parity with pandas. Older pandas support `ignore_index` as well: ```py >>> pdf = pd.DataFrame({"a": [1, 2, 3, 4, 5, None, 7], "b": [7, 6, 5, 4, 3, 2, 1]}, index=np.random.rand(7)) >>> pdf.sort_values("b", ignore_index=True) a b 0 7.0 1 1 NaN 2 2 5.0 3 3 4.0 4 4 3.0 5 5 2.0 6 6 1.0 7 >>> pd.__version__ '1.0.0' ``` ### Does this PR introduce _any_ user-facing change? Yes. `ignore_index` of `Series.sort_values` is supported. ```py >>> psdf = ps.DataFrame({"a": [1, 2, 3, 4, 5, None, 7], "b": [7, 6, 5, 4, 3, 2, 1]}, index=np.random.rand(7)) >>> psdf a b 0.971253 1.0 7 0.401039 2.0 6 0.322310 3.0 5 0.932521 4.0 4 0.058432 5.0 3 0.122754 NaN 2 0.842971 7.0 1 >>> psdf.sort_values("b", ignore_index=True) a b 0 7.0 1 1 NaN 2 2 5.0 3 3 4.0 4 4 3.0 5 5 2.0 6 6 1.0 7 ``` ### How was this patch tested? Unit tests. Closes apache#35794 from xinrong-databricks/frame.sort_values. Authored-by: Xinrong Meng <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
- Loading branch information
1 parent
34e3029
commit 36023c2
Showing
2 changed files
with
73 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters