TheNeuralBit commented on a change in pull request #15944:
URL: https://github.com/apache/beam/pull/15944#discussion_r765077294



##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -228,6 +228,16 @@ def droplevel(self, level, axis):
             preserves_partition_by=partitionings.Arbitrary()
             if axis in (1, 'column') else partitionings.Singleton()))
 
+  @frame_base.with_docs_from(pd.DataFrame)
+  @frame_base.args_to_kwargs(pd.DataFrame)
+  def swaplevel(self, **kwargs):
+    return frame_base.DeferredFrame.wrap(
+        expressions.ComputedExpression(
+            'swaplevel',
+            lambda df: df.swaplevel(**kwargs), [self._expr],
+            requires_partition_by=partitionings.Arbitrary(),
+            preserves_partition_by=partitionings.Arbitrary()))

Review comment:
       I wouldn't think this should preserve Index partitioning, since it 
modifies the index. But our test framework does verify this.
   
   It turns out this expression _does_ preserve index partitioning, since we 
generate hashes by summing hashes on the individual index levels, which is 
independent of the order of the index levels.




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


Reply via email to