简体   繁体   English

Select PCollection 中的一些列(Apache Beam、Python)

[英]Select some columns from PCollection (Apache Beam, Python)

I have the following PCollection:我有以下 PCollection: 在此处输入图像描述

And I want to select only 2 columns from that PCollection.我只想 select 来自该 PCollection 的 2 列。 I tried to do:我试着做:

def cut_data(data):
    return data[["WebSpeedRef", "WebSpeedAct"]]

data_min = data_json | 'min' >> beam.Map(cut_data)

but got an error.但出现错误。 What is the simplest way to accomplish this.完成此操作的最简单方法是什么。

You could do this:你可以这样做:

disired_columns = (
    dataset
    | beam.Map(lambda x: [x["column1"], x["column2"]])
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从PCollection Apache Beam Python创建N个元素组 - How to create groups of N elements from a PCollection Apache Beam Python 如何在使用 python SDK 将 BIG QUERY 中的数据读取到 apache 光束中的 PCollection 时将源列重命名为目标列名 - how to rename the source columns to target column names while reading the data from BIG QUERY into PCollection in apache beam using python SDK Apache 光束列表到 PCollection - Apache beam list to PCollection Google Dataflow / Apache Beam Python - 来自PCollection的Side-Input会导致性能下降 - Google Dataflow / Apache Beam Python - Side-Input from PCollection kills performance python中的Apache Beam:如何在另一个PCollection上重用完全相同的转换 - Apache Beam in python: How to reuse exactly the same transform on another PCollection 我可以使用 python 对 Apache beam PCollection 中的项目进行排序吗? - Can I sort the items in an Apache beam PCollection using python? 如何使用Apache Beam在Python中将有界pcollection转换为无界? - How to transform bounded pcollection to unbounded in Python with Apache Beam? 使用python的Apache Beam中PCollection内几个字段的最大值和最小值 - Max and Min for several fields inside PCollection in apache beam with python Apache Beam-Python:如何通过累积获取PCollection的前10个元素? - Apache Beam - Python : How to get the top 10 elements of a PCollection with Accumulation? 从 apache beam pcollection 返回什么以写入 bigquery - What to return from apache beam pcollection to write to bigquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM