TheNeuralBit commented on a change in pull request #15827:
URL: https://github.com/apache/beam/pull/15827#discussion_r762248971
##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -1277,6 +1277,74 @@ def align(self, other, join, axis, level, method,
**kwargs):
requires_partition_by=partitionings.Arbitrary(),
preserves_partition_by=partitionings.Singleton())
+ @frame_base.with_docs_from(pd.Series)
+ @frame_base.args_to_kwargs(pd.Series)
+ @frame_base.populate_defaults(pd.Series)
+ def idxmin(self, **kwargs):
+ def compute_idxmin(s):
+ min_index = s.idxmin(**kwargs)
+ if pd.isna(min_index):
+ return s
+ else:
+ return s.loc[[min_index]]
+
+ # Avoids empty Series error when evaluating proxy
+ index_dtype = self._expr.proxy().index.dtype
+ index = pd.Index([], dtype=index_dtype)
+ proxy = self._expr.proxy().copy()
+ proxy.index = index
+ proxy = proxy.append(
+ pd.Series([np.inf], index=np.asarray(['0']).astype(proxy.index.dtype)))
+
+ idx_min = expressions.ComputedExpression(
+ 'idx_min',
+ compute_idxmin, [self._expr],
+ proxy=proxy,
+ requires_partition_by=partitionings.Index(),
+ preserves_partition_by=partitionings.Singleton())
Review comment:
```suggestion
requires_partition_by=partitionings.Arbitrary(),
preserves_partition_by=partitionings.Arbitrary())
```
Actually I think this partition spec should be sufficient (here and in the
equivalent expressions elsewhere).
--
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]