Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-9547] Add support for xs on DataFrame and Series #15078

Merged
merged 2 commits into from
Jun 25, 2021

Conversation

TheNeuralBit
Copy link
Member

This PR adds support for xs on DataFrame and Series instances. xs is really just a specialized filter on the index, which at first glance is trivially elementwise. However it is complicated by the fact that it raises a KeyError when the keyed value does not exist. In order to raise this error correctly (at execution time) in a distributed context, we need to know when we're processing the partition that should contain the key. In order to do this we wrap the key in a DeferredSeries and use Index partitioning to co-locate it, thus if the key is present in a partition, we know to raise an error if it doesn't exist in the target frame.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Python --- Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status Build Status Build Status --- Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@codecov
Copy link

codecov bot commented Jun 24, 2021

Codecov Report

Merging #15078 (287d72b) into master (e520b54) will increase coverage by 0.01%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15078      +/-   ##
==========================================
+ Coverage   83.76%   83.78%   +0.01%     
==========================================
  Files         439      439              
  Lines       59176    59211      +35     
==========================================
+ Hits        49566    49607      +41     
+ Misses       9610     9604       -6     
Impacted Files Coverage Δ
sdks/python/apache_beam/dataframe/frames.py 94.48% <95.83%> (+0.16%) ⬆️
...eam/runners/interactive/interactive_environment.py 90.33% <0.00%> (-0.38%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 93.73% <0.00%> (ø)
sdks/python/apache_beam/typehints/schemas.py 94.20% <0.00%> (+0.05%) ⬆️
...ks/python/apache_beam/runners/worker/data_plane.py 91.21% <0.00%> (+0.30%) ⬆️
sdks/python/apache_beam/internal/metrics/metric.py 87.23% <0.00%> (+1.06%) ⬆️
...che_beam/runners/interactive/interactive_runner.py 92.52% <0.00%> (+1.86%) ⬆️
.../python/apache_beam/testing/test_stream_service.py 93.02% <0.00%> (+4.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e520b54...287d72b. Read the comment docs.

@TheNeuralBit
Copy link
Member Author

R: @rohdesamuel

Comment on lines 879 to 887
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some comments for these conditionals?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@rohdesamuel rohdesamuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm just needs a little more comments

@TheNeuralBit
Copy link
Member Author

Run Python PreCommit

1 similar comment
@TheNeuralBit
Copy link
Member Author

Run Python PreCommit

@TheNeuralBit TheNeuralBit merged commit 225fcd0 into apache:master Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants