You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2023/12/20 10:57:16 UTC

[PR] [SPARK-46465][PYTHON][CONNECT] Implement `Column.isNaN` [spark]

zhengruifeng opened a new pull request, #44422:
URL: https://github.com/apache/spark/pull/44422

   ### What changes were proposed in this pull request?
   add `Column.isNaN` in pyspark
   
   ### Why are the changes needed?
   `Column.isNaN` was added in scala since 1.5.0, but it is still missing in python
   this pr adds it for parity
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes
   
   ```
   In [1]: from pyspark.sql import Row
   
   In [2]: df = spark.createDataFrame([Row(name='Tom', height=80.0), Row(name='Alice', height=float('nan'))])
   
   In [3]: df.show()
   +-----+------+
   | name|height|
   +-----+------+
   |  Tom|  80.0|
   |Alice|   NaN|
   +-----+------+
   
   
   In [4]: df.filter(df.height.isNaN()).show()
   +-----+------+
   | name|height|
   +-----+------+
   |Alice|   NaN|
   +-----+------+
   ```
   
   
   ### How was this patch tested?
   added doctest
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   no


-- 
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


Re: [PR] [SPARK-46465][PYTHON][CONNECT] Add `Column.isNaN` in PySpark [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #44422: [SPARK-46465][PYTHON][CONNECT] Add `Column.isNaN` in PySpark
URL: https://github.com/apache/spark/pull/44422


-- 
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


Re: [PR] [SPARK-46465][PYTHON][CONNECT] Add `Column.isNaN` in PySpark [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #44422:
URL: https://github.com/apache/spark/pull/44422#discussion_r1433288955


##########
python/pyspark/sql/column.py:
##########
@@ -1153,9 +1153,22 @@ def isin(self, *cols: Any) -> "Column":
     >>> df.filter(df.height.isNotNull()).collect()
     [Row(name='Tom', height=80)]
     """
+    _isNaN_doc = """
+    True if the current expression is NaN.
+
+    .. versionadded:: 4.0.0
+
+    Examples
+    --------
+    >>> from pyspark.sql import Row
+    >>> df = spark.createDataFrame([Row(name='Tom', height=80.0), Row(name='Alice', height=float('nan'))])

Review Comment:
   ```suggestion
       >>> df = spark.createDataFrame(
       ...     [Row(name='Tom', height=80.0), Row(name='Alice', height=float('nan'))])
   ```



-- 
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


Re: [PR] [SPARK-46465][PYTHON][CONNECT] Add `Column.isNaN` in PySpark [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #44422:
URL: https://github.com/apache/spark/pull/44422#discussion_r1433288955


##########
python/pyspark/sql/column.py:
##########
@@ -1153,9 +1153,22 @@ def isin(self, *cols: Any) -> "Column":
     >>> df.filter(df.height.isNotNull()).collect()
     [Row(name='Tom', height=80)]
     """
+    _isNaN_doc = """
+    True if the current expression is NaN.
+
+    .. versionadded:: 4.0.0
+
+    Examples
+    --------
+    >>> from pyspark.sql import Row
+    >>> df = spark.createDataFrame([Row(name='Tom', height=80.0), Row(name='Alice', height=float('nan'))])

Review Comment:
   ```suggestion
       >>> df = spark.createDataFrame(
       ...     [Row(name='Tom', height=80.0), Row(name='Alice', height=float('nan'))])
   ```



-- 
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


Re: [PR] [SPARK-46465][PYTHON][CONNECT] Add `Column.isNaN` in PySpark [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #44422:
URL: https://github.com/apache/spark/pull/44422#issuecomment-1865292230

   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