dgd-contributor opened a new pull request #33945:
URL: https://github.com/apache/spark/pull/33945
### What changes were proposed in this pull request?
Support Series.\_\_and\_\_ and Series.\_\_or\_\_ for integral type
### Why are the changes needed?
Follow Pandas API as much as possible
``` python
>>> pser1 = pd.Series([1, 2, 3])
>>> pser2 = pd.Series([4, 5, 6])
>>> pser1 & pser2
0 False
1 False
2 True
dtype: bool
```
### Does this PR introduce _any_ user-facing change?
Yes.
Before
``` python
>>> pser1 = ps.Series([1, 2, 3])
>>> pser2 = ps.Series([4, 5, 6])
>>> pser3 = ps.Series([True, False, True])
>>> pser1 & pser2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dgd/spark/python/pyspark/pandas/base.py", line 420, in __and__
return self._dtype_op.__and__(self, other)
File "/Users/dgd/spark/python/pyspark/pandas/data_type_ops/base.py", line
317, in __and__
raise TypeError("Bitwise and can not be applied to %s." %
self.pretty_name)
TypeError: Bitwise and can not be applied to integrals.
>>> pser1 & pser3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dgd/spark/python/pyspark/pandas/base.py", line 420, in __and__
return self._dtype_op.__and__(self, other)
File "/Users/dgd/spark/python/pyspark/pandas/data_type_ops/base.py", line
317, in __and__
raise TypeError("Bitwise and can not be applied to %s." %
self.pretty_name)
TypeError: Bitwise and can not be applied to integrals.
```
After
``` python
>>> pser1 = ps.Series([1, 2, 3])
>>> pser2 = ps.Series([4, 5, 6])
>>> pser3 = ps.Series([True, False, True])
>>> pser1 & pser2
0 0
1 0
2 2
dtype: int64
>>> pser1 & pser3
0 True
1 False
2 True
dtype: bool
>>>
```
### How was this patch tested?
exist tests and add new 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: [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]