[
https://issues.apache.org/jira/browse/BEAM-9547?focusedWorklogId=607990&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-607990
]
ASF GitHub Bot logged work on BEAM-9547:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jun/21 16:53
Start Date: 07/Jun/21 16:53
Worklog Time Spent: 10m
Work Description: rohdesamuel commented on a change in pull request
#14922:
URL: https://github.com/apache/beam/pull/14922#discussion_r646776193
##########
File path: sdks/python/apache_beam/dataframe/frames.py
##########
@@ -458,6 +458,32 @@ def size(self):
requires_partition_by=partitionings.Singleton(),
preserves_partition_by=partitionings.Singleton()))
+ def length(self):
+ """Alternative to ``len(df)`` which returns a deferred result that can be
+ used in arithmetic with :class:`DeferredSeries` or
+ :class:`DeferredDataFrame` instances."""
+ lengths = expressions.ComputedExpression(
+ 'get_lengths',
+ # Wrap scalar results in a Series for easier concatenation later
+ lambda df: pd.Series(len(df)),
+ [self._expr],
+ requires_partition_by=partitionings.Arbitrary(),
+ preserves_partition_by=partitionings.Singleton())
+
+ with expressions.allow_non_parallel_operations(True):
+ return frame_base.DeferredFrame.wrap(
+ expressions.ComputedExpression(
+ 'sum_lengths',
+ lambda lengths: lengths.sum(), [lengths],
+ requires_partition_by=partitionings.Singleton(),
+ preserves_partition_by=partitionings.Singleton()))
+
+ def __len__(self):
+ raise frame_base.WontImplementError(
+ "len(df) is not currently supported because it produces a non-deferred
"
+ "result. Consider using df.length() instead.",
+ reason="non-deferred-result")
Review comment:
ohh that's really weird! Good to know though
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 607990)
Time Spent: 107h 10m (was: 107h)
> Implement all pandas operations (or raise WontImplementError)
> -------------------------------------------------------------
>
> Key: BEAM-9547
> URL: https://issues.apache.org/jira/browse/BEAM-9547
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core
> Reporter: Brian Hulette
> Assignee: Robert Bradshaw
> Priority: P2
> Labels: dataframe-api
> Time Spent: 107h 10m
> Remaining Estimate: 0h
>
> We should have an implementation for every DataFrame, Series, and GroupBy
> method. Everything that's not possible to implement should get a default
> implementation that raises WontImplementError
> SeeĀ https://github.com/apache/beam/pull/10757#discussion_r389132292
> Progress at the individual operation level is tracked in a
> [spreadsheet|https://docs.google.com/spreadsheets/d/1hHAaJ0n0k2tw465ORs5tfdy4Lg0DnGWIQ53cLjAhel0/edit],
> consider requesting edit access if you'd like to help out.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)