ueshin commented on a change in pull request #34005:
URL: https://github.com/apache/spark/pull/34005#discussion_r710324982
##########
File path: python/pyspark/pandas/base.py
##########
@@ -873,7 +873,11 @@ def isin(self: IndexOpsLike, values: Sequence[Any]) ->
IndexOpsLike:
)
values = values.tolist() if isinstance(values, np.ndarray) else
list(values)
- return self._with_new_scol(self.spark.column.isin([SF.lit(v) for v in
values]))
+
+ other = [SF.lit(v) for v in values]
+ scol = self.spark.column.isin(other)
+
+ return self._with_new_scol(F.when(scol.isNull(),
False).otherwise(scol))
Review comment:
I guess `F.coalesce` is better? `F.coalesce(scol, F.lit(False))`
##########
File path: python/pyspark/pandas/base.py
##########
@@ -873,7 +873,11 @@ def isin(self: IndexOpsLike, values: Sequence[Any]) ->
IndexOpsLike:
)
values = values.tolist() if isinstance(values, np.ndarray) else
list(values)
- return self._with_new_scol(self.spark.column.isin([SF.lit(v) for v in
values]))
+
+ other = [SF.lit(v) for v in values]
+ scol = self.spark.column.isin(other)
+
+ return self._with_new_scol(F.when(scol.isNull(),
False).otherwise(scol))
Review comment:
Btw, we can mange `field` here?
`field=self._internal.data_fields[0].copy(dtype=np.dtype("bool"),
spark_type=BooleanType(), nullable=False)`
--
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]