You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/13 23:55:06 UTC
[GitHub] [spark] xinrong-databricks opened a new pull request, #36186: Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
xinrong-databricks opened a new pull request, #36186:
URL: https://github.com/apache/spark/pull/36186
### What changes were proposed in this pull request?
Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
### Why are the changes needed?
To reach parity with pandas API.
### Does this PR introduce _any_ user-facing change?
Yes. `ignore_index`s of `Series.sort_values` and `Series.sort_index` are supported.
### How was this patch tested?
Unit tests.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] itholic commented on a diff in pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
itholic commented on code in PR #36186:
URL: https://github.com/apache/spark/pull/36186#discussion_r850865724
##########
python/pyspark/pandas/series.py:
##########
@@ -2834,57 +2855,69 @@ def sort_index(
na_position : {‘first’, ‘last’}, default ‘last’
first puts NaNs at the beginning, last puts NaNs at the end. Not implemented for
MultiIndex.
+ ignore_index : bool, default False
+ If True, the resulting axis will be labeled 0, 1, …, n - 1.
+
+ .. versionadded:: 3.4.0
Returns
-------
sorted_obj : Series
Examples
--------
- >>> df = ps.Series([2, 1, np.nan], index=['b', 'a', np.nan])
+ >>> s = ps.Series([2, 1, np.nan], index=['b', 'a', np.nan])
- >>> df.sort_index()
+ >>> s.sort_index()
Review Comment:
+1
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -998,6 +999,10 @@ def test_sort_values(self):
self.assert_eq(psser, pser.sort_values())
self.assert_eq(psdf, pdf)
+ psser.sort_values(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_values(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
```suggestion
psser.sort_values(inplace=True, ascending=False, ignore_index=True)
pser.sort_values(inplace=True, ascending=False, ignore_index=True)
self.assert_eq(psser, pser)
self.assert_eq(psdf, pdf)
```
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -1032,6 +1039,10 @@ def test_sort_index(self):
self.assert_eq(psser, pser.sort_index())
self.assert_eq(psdf, pdf)
+ psser.sort_index(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_index(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
```suggestion
psser.sort_index(inplace=True, ascending=False, ignore_index=True)
pser.sort_index(inplace=True, ascending=False, ignore_index=True)
self.assert_eq(psser, pser)
self.assert_eq(psdf, pdf)
```
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] itholic commented on pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
itholic commented on PR #36186:
URL: https://github.com/apache/spark/pull/36186#issuecomment-1100953833
Thanks, Looks good to me.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon closed pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
URL: https://github.com/apache/spark/pull/36186
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] xinrong-databricks commented on a diff in pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on code in PR #36186:
URL: https://github.com/apache/spark/pull/36186#discussion_r851411197
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -998,6 +999,10 @@ def test_sort_values(self):
self.assert_eq(psser, pser.sort_values())
self.assert_eq(psdf, pdf)
+ psser.sort_values(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_values(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
Shall we be consistent with https://github.com/apache/spark/blob/master/python/pyspark/pandas/tests/test_series.py#L1028-L1033 instead? Thanks!
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -1032,6 +1039,10 @@ def test_sort_index(self):
self.assert_eq(psser, pser.sort_index())
self.assert_eq(psdf, pdf)
+ psser.sort_index(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_index(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
ditto.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] xinrong-databricks commented on pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36186:
URL: https://github.com/apache/spark/pull/36186#issuecomment-1099462537
@ueshin @HyukjinKwon @itholic Thanks!
Please refer to https://github.com/xinrong-databricks/spark/actions/workflows/build_and_test.yml for test results.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #36186:
URL: https://github.com/apache/spark/pull/36186#issuecomment-1101920337
Merged to master.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] xinrong-databricks commented on a diff in pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on code in PR #36186:
URL: https://github.com/apache/spark/pull/36186#discussion_r851416809
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -998,6 +999,10 @@ def test_sort_values(self):
self.assert_eq(psser, pser.sort_values())
self.assert_eq(psdf, pdf)
+ psser.sort_values(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_values(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
Sounds good!
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] ueshin commented on a diff in pull request #36186: [SPARK-38903][PYTHON] Implement `ignore_index` of `Series.sort_values` and `Series.sort_index`
Posted by GitBox <gi...@apache.org>.
ueshin commented on code in PR #36186:
URL: https://github.com/apache/spark/pull/36186#discussion_r851415370
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -998,6 +999,10 @@ def test_sort_values(self):
self.assert_eq(psser, pser.sort_values())
self.assert_eq(psdf, pdf)
+ psser.sort_values(inplace=True, ascending=False, ignore_index=True)
+ self.assert_eq(psser, pser.sort_values(ascending=False, ignore_index=True))
+ self.assert_eq(psdf, pdf)
Review Comment:
Shall we put the comment here as well, then?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org