TheNeuralBit commented on a change in pull request #15078:
URL: https://github.com/apache/beam/pull/15078#discussion_r658985643
##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -869,6 +869,67 @@ def mask(self, cond, **kwargs):
"""mask is not parallelizable when ``errors="ignore"`` is specified."""
return self.where(~cond, **kwargs)
+ @frame_base.with_docs_from(pd.DataFrame)
+ @frame_base.args_to_kwargs(pd.DataFrame)
+ @frame_base.populate_defaults(pd.DataFrame)
+ def xs(self, key, axis, level, **kwargs):
+ """Note that ``xs(axis='index')`` will raise a ``KeyError`` at execution
+ time if the key does not exist in the index."""
+
+ if axis in ('columns', 1):
+ return frame_base.DeferredFrame.wrap(
+ expressions.ComputedExpression(
+ 'xs',
+ lambda df: df.xs(key, axis=axis, **kwargs), [self._expr],
+ requires_partition_by=partitionings.Arbitrary(),
+ preserves_partition_by=partitionings.Arbitrary()))
+ elif axis not in ('index', 0):
+ raise ValueError(
Review comment:
Done
--
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]