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

Dataframe wordcount example. #12889

Merged
merged 2 commits into from
Sep 22, 2020
Merged

Conversation

robertwb
Copy link
Contributor

Also add reference in release notes.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK 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
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang 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 --- --- --- ---

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.

| 'Split' >> beam.FlatMap(
lambda line: re.findall(r'[\w]+', line)).with_output_types(str)
# Map to Row objects to generate a schema suitable for conversion to a dataframe.
| 'ToRows' >> beam.Map(lambda word: beam.Row(word=word)))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use Select here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually toyed with that, but it's not as natural (or time-saving) for 1-field schemas.

Copy link
Member

@TheNeuralBit TheNeuralBit left a comment

Choose a reason for hiding this comment

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

LGTM

df = to_dataframe(words)
df['count'] = 1
counted = df.groupby('word').sum()
counted.to_csv(known_args.output)
Copy link
Member

Choose a reason for hiding this comment

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

It could be nice to tee the counted back to a PCollection and print it as an example of to_pcollection. That's easier to do once unbatching is the default, I can add it as part of #12882 WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, let's do that.

CHANGES.md Outdated
* X feature added (Java/Python) ([BEAM-X](https://issues.apache.org/jira/browse/BEAM-X)).

## Breaking Changes

* X behavior was changed ([BEAM-X](https://issues.apache.org/jira/browse/BEAM-X)).
* Python 2 and Python 3.5 support dropped.
* Pandas 1.x allowed. Older version of Pandas may still be used, but may not be as well tested.
Copy link
Member

Choose a reason for hiding this comment

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

Should this comment be part of the Dataframes note above? I don't think pandas 1.x support has any broader implications

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes more sense here--the main implication here is how diamond dependencies might get resolved.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, makes sense

@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #12889 into master will increase coverage by 0.00%.
The diff coverage is 91.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #12889   +/-   ##
=======================================
  Coverage   82.32%   82.33%           
=======================================
  Files         452      453    +1     
  Lines       54016    54040   +24     
=======================================
+ Hits        44471    44496   +25     
+ Misses       9545     9544    -1     
Impacted Files Coverage Δ
...python/apache_beam/examples/wordcount_dataframe.py 91.66% <91.66%> (ø)
sdks/python/apache_beam/runners/common.py 88.75% <0.00%> (-0.45%) ⬇️
...ks/python/apache_beam/runners/worker/sdk_worker.py 88.80% <0.00%> (-0.18%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 94.58% <0.00%> (+0.13%) ⬆️
...nners/portability/fn_api_runner/worker_handlers.py 80.75% <0.00%> (+0.17%) ⬆️
sdks/python/apache_beam/io/iobase.py 84.33% <0.00%> (+0.28%) ⬆️
...ks/python/apache_beam/runners/worker/data_plane.py 89.90% <0.00%> (+1.22%) ⬆️

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 1b26660...4146e55. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants