[ 
https://issues.apache.org/jira/browse/BEAM-12564?focusedWorklogId=665882&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-665882
 ]

ASF GitHub Bot logged work on BEAM-12564:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Oct/21 00:41
            Start Date: 17/Oct/21 00:41
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit commented on a change in pull request 
#15729:
URL: https://github.com/apache/beam/pull/15729#discussion_r730083674



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1098,6 +1098,23 @@ def fn(s):
         requires_partition_by=partitionings.Arbitrary(),
         preserves_partition_by=partitionings.Arbitrary())
 
+  @property  # type: ignore
+  @frame_base.with_docs_from(pd.Series)
+  def hasnans(self):
+    has_nans = expressions.ComputedExpression(
+        'has_nans',
+        lambda s: pd.Series(s.hasnans), [self._expr],
+        requires_partition_by=partitionings.Index(),
+        preserves_partition_by=partitionings.Singleton())
+
+    with expressions.allow_non_parallel_operations():
+      return frame_base.DeferredFrame.wrap(
+          expressions.ComputedExpression(
+              'combine',
+              lambda s: s.all(), [has_nans],

Review comment:
       Is `all()` correct here? I think this should be `s.any()` (it should 
return True if any of the partitions is True, meaning there's a NaN)
   
   It's surprising this wasn't caught in testing

##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1098,6 +1098,23 @@ def fn(s):
         requires_partition_by=partitionings.Arbitrary(),
         preserves_partition_by=partitionings.Arbitrary())
 
+  @property  # type: ignore
+  @frame_base.with_docs_from(pd.Series)
+  def hasnans(self):
+    has_nans = expressions.ComputedExpression(
+        'has_nans',
+        lambda s: pd.Series(s.hasnans), [self._expr],
+        requires_partition_by=partitionings.Index(),
+        preserves_partition_by=partitionings.Singleton())
+
+    with expressions.allow_non_parallel_operations():
+      return frame_base.DeferredFrame.wrap(
+          expressions.ComputedExpression(
+              'combine',

Review comment:
       nit:
   ```suggestion
                 'combine_hasnans',
   ```

##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1098,6 +1098,23 @@ def fn(s):
         requires_partition_by=partitionings.Arbitrary(),
         preserves_partition_by=partitionings.Arbitrary())
 
+  @property  # type: ignore
+  @frame_base.with_docs_from(pd.Series)
+  def hasnans(self):
+    has_nans = expressions.ComputedExpression(
+        'has_nans',
+        lambda s: pd.Series(s.hasnans), [self._expr],
+        requires_partition_by=partitionings.Index(),

Review comment:
       ```suggestion
           requires_partition_by=partitionings.Arbitrary(),
   ```
   
   This expression doesn't have a particular partitioning requirement. 
Partitioning by Index is for when the expression need to co-locate data for 
some reason (e.g. a join operation, or to group by some key for an aggregation).

##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1098,6 +1098,23 @@ def fn(s):
         requires_partition_by=partitionings.Arbitrary(),
         preserves_partition_by=partitionings.Arbitrary())
 
+  @property  # type: ignore
+  @frame_base.with_docs_from(pd.Series)
+  def hasnans(self):
+    has_nans = expressions.ComputedExpression(
+        'has_nans',

Review comment:
       nit: 
   ```suggestion
           'hasnans',
   ```

##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1098,6 +1098,23 @@ def fn(s):
         requires_partition_by=partitionings.Arbitrary(),
         preserves_partition_by=partitionings.Arbitrary())
 
+  @property  # type: ignore
+  @frame_base.with_docs_from(pd.Series)
+  def hasnans(self):
+    has_nans = expressions.ComputedExpression(
+        'has_nans',
+        lambda s: pd.Series(s.hasnans), [self._expr],
+        requires_partition_by=partitionings.Index(),
+        preserves_partition_by=partitionings.Singleton())
+
+    with expressions.allow_non_parallel_operations():
+      return frame_base.DeferredFrame.wrap(
+          expressions.ComputedExpression(
+              'combine',
+              lambda s: s.all(), [has_nans],

Review comment:
       This looks like a bug in the `frames_test` framework. 
https://github.com/apache/beam/pull/15734 seems to fix it.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 665882)
    Time Spent: 0.5h  (was: 20m)

> Implement Series.hasnans
> ------------------------
>
>                 Key: BEAM-12564
>                 URL: https://issues.apache.org/jira/browse/BEAM-12564
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-dataframe
>            Reporter: Brian Hulette
>            Assignee: Benjamin Gonzalez
>            Priority: P3
>             Fix For: 2.35.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Add an implementation of 
> [Series.hasnans|https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.hasnans.html]
>  for DeferredSeries. It should be fully unit tested with some combination of 
> pandas_doctests_test.py and frames_test.py.
> https://github.com/apache/beam/pull/14274 is an example of a typical PR that 
> adds new operations. See 
> https://lists.apache.org/thread.html/r8ffe96d756054610dfdb4e849ffc6a741e826d15ba7e5bdeee1b4266%40%3Cdev.beam.apache.org%3E
>  for background on the DataFrame API.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to