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/15 22:45:01 UTC
[GitHub] [spark] xinrong-databricks opened a new pull request, #36215: Implement `inplace` and `columns` parameters of `Series.drop`
xinrong-databricks opened a new pull request, #36215:
URL: https://github.com/apache/spark/pull/36215
### What changes were proposed in this pull request?
Implement `inplace` and `columns` parameters of `Series.drop`.
### Why are the changes needed?
Increase pandas API coverage.
### Does this PR introduce _any_ user-facing change?
Yes. `inplace` and `columns` parameters of `Series.drop` are supported now.
### 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] xinrong-databricks commented on pull request #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1101795486
Thanks @ueshin , good catch! Fixed.
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1105948369
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] itholic commented on a diff in pull request #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
itholic commented on code in PR #36215:
URL: https://github.com/apache/spark/pull/36215#discussion_r854669924
##########
python/pyspark/pandas/series.py:
##########
@@ -2377,10 +2379,18 @@ def drop(
----------
labels : single label or list-like
Index labels to drop.
- index : None
+ index : single label or list-like
Review Comment:
+1
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1101571390
Please refer to https://github.com/xinrong-databricks/spark/actions/runs/2185003953 for test results.
@ueshin @HyukjinKwon @itholic Thanks!
--
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 pull request #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
ueshin commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1101654662
When `inplace=True`, it shouldn't update the anchor:
```py
>>> pdf = pd.DataFrame({"a": np.arange(3)}, index=['A', 'B', 'C'])
>>> pdf
a
A 0
B 1
C 2
>>> s = pdf.a
>>> s.drop(index=['B', 'C'], inplace=True)
>>> s
A 0
Name: a, dtype: int64
>>> pdf
a
A 0
B 1
C 2
```
whereas:
```py
>>> psdf = ps.DataFrame({"a": np.arange(3)}, index=['A', 'B', 'C'])
>>> ss = psdf.a
>>> ss.drop(index=['B', 'C'], inplace=True)
>>> ss
A 0
Name: a, dtype: int64
>>> psdf
a
A 0
```
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
itholic commented on code in PR #36215:
URL: https://github.com/apache/spark/pull/36215#discussion_r853657776
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -1749,14 +1759,22 @@ def test_drop(self):
with self.assertRaisesRegex(ValueError, msg):
psser.drop(["lama", ["cow", "falcon"]])
- msg = "Cannot specify both 'labels' and 'index'"
+ msg = "Cannot specify both 'labels' and 'index'/'columns'"
with self.assertRaisesRegex(ValueError, msg):
psser.drop("lama", index="cow")
+ with self.assertRaisesRegex(ValueError, msg):
+ psser.drop("lama", columns="cow")
+
msg = r"'Key length \(2\) exceeds index depth \(3\)'"
with self.assertRaisesRegex(KeyError, msg):
psser.drop(("lama", "speed", "x"))
+ psser.drop({"lama": "speed"}, inplace=True)
+ pser.drop({"lama": "speed"}, inplace=True)
+ self.assert_eq(psser, pser)
+ self.assert_eq(psdf, pdf)
Review Comment:
Oh, can we add a one test for chained case ?
e.g.
```python
(psser + 1).drop({"lama": "speed"}, inplace=True)
(pser + 1).drop({"lama": "speed"}, inplace=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] xinrong-databricks commented on pull request #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1101866682
Please refer to https://github.com/xinrong-databricks/spark/actions/runs/2186250376 for test results.
@ueshin @HyukjinKwon @itholic Thanks!
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1102922519
Rebased for CI.
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on code in PR #36215:
URL: https://github.com/apache/spark/pull/36215#discussion_r854370085
##########
python/pyspark/pandas/tests/test_series.py:
##########
@@ -1749,14 +1759,22 @@ def test_drop(self):
with self.assertRaisesRegex(ValueError, msg):
psser.drop(["lama", ["cow", "falcon"]])
- msg = "Cannot specify both 'labels' and 'index'"
+ msg = "Cannot specify both 'labels' and 'index'/'columns'"
with self.assertRaisesRegex(ValueError, msg):
psser.drop("lama", index="cow")
+ with self.assertRaisesRegex(ValueError, msg):
+ psser.drop("lama", columns="cow")
+
msg = r"'Key length \(2\) exceeds index depth \(3\)'"
with self.assertRaisesRegex(KeyError, msg):
psser.drop(("lama", "speed", "x"))
+ psser.drop({"lama": "speed"}, inplace=True)
+ pser.drop({"lama": "speed"}, inplace=True)
+ self.assert_eq(psser, pser)
+ self.assert_eq(psdf, pdf)
Review Comment:
Added, thanks!
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
URL: https://github.com/apache/spark/pull/36215
--
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 #36215: [SPARK-38938][PYTHON] Implement `inplace` and `columns` parameters of `Series.drop`
Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on PR #36215:
URL: https://github.com/apache/spark/pull/36215#issuecomment-1105819531
Rebased to update `supported_pandas_api.rst`.
--
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