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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to