本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
SelectFromCollection 類別
在 DynamicFrameCollection
中選擇一個 DynamicFrame
。
範例
此範例使用 SelectFromCollection
從 DynamicFrameCollection
中選取 DynamicFrame
。
範例資料集
該範例從稱為 split_rows_collection
的 DynamicFrameCollection
中選取兩個 DynamicFrames
。以下是 split_rows_collection
中的索引鍵清單。
dict_keys(['high', 'low'])
範例程式碼
# Example: Use SelectFromCollection to select # DynamicFrames from a DynamicFrameCollection from pyspark.context import SparkContext from awsglue.context import GlueContext from awsglue.transforms import SelectFromCollection # Create GlueContext sc = SparkContext.getOrCreate() glueContext = GlueContext(sc) # Select frames and inspect entries frame_low = SelectFromCollection.apply(dfc=split_rows_collection, key="low") frame_low.toDF().show() frame_high = SelectFromCollection.apply(dfc=split_rows_collection, key="high") frame_high.toDF().show()
+---+-----+------------------------+-------------------------+ | id|index|contact_details.val.type|contact_details.val.value| +---+-----+------------------------+-------------------------+ | 1| 0| fax| 202-225-3307| | 1| 1| phone| 202-225-5731| | 2| 0| fax| 202-225-3307| | 2| 1| phone| 202-225-5731| | 3| 0| fax| 202-225-3307| | 3| 1| phone| 202-225-5731| | 4| 0| fax| 202-225-3307| | 4| 1| phone| 202-225-5731| | 5| 0| fax| 202-225-3307| | 5| 1| phone| 202-225-5731| | 6| 0| fax| 202-225-3307| | 6| 1| phone| 202-225-5731| | 7| 0| fax| 202-225-3307| | 7| 1| phone| 202-225-5731| | 8| 0| fax| 202-225-3307| | 8| 1| phone| 202-225-5731| | 9| 0| fax| 202-225-3307| | 9| 1| phone| 202-225-5731| | 10| 0| fax| 202-225-6328| | 10| 1| phone| 202-225-4576| +---+-----+------------------------+-------------------------+ only showing top 20 rows +---+-----+------------------------+-------------------------+ | id|index|contact_details.val.type|contact_details.val.value| +---+-----+------------------------+-------------------------+ | 11| 0| fax| 202-225-6328| | 11| 1| phone| 202-225-4576| | 11| 2| twitter| RepTrentFranks| | 12| 0| fax| 202-225-6328| | 12| 1| phone| 202-225-4576| | 12| 2| twitter| RepTrentFranks| | 13| 0| fax| 202-225-6328| | 13| 1| phone| 202-225-4576| | 13| 2| twitter| RepTrentFranks| | 14| 0| fax| 202-225-6328| | 14| 1| phone| 202-225-4576| | 14| 2| twitter| RepTrentFranks| | 15| 0| fax| 202-225-6328| | 15| 1| phone| 202-225-4576| | 15| 2| twitter| RepTrentFranks| | 16| 0| fax| 202-225-6328| | 16| 1| phone| 202-225-4576| | 16| 2| twitter| RepTrentFranks| | 17| 0| fax| 202-225-6328| | 17| 1| phone| 202-225-4576| +---+-----+------------------------+-------------------------+ only showing top 20 rows
方法
__call__(dfc, key, transformation_ctx = "")
從 DynamicFrameCollection
取得一個 DynamicFrame
。
-
dfc
– 應該從其中選取DynamicFrame
的DynamicFrameCollection
(必要)。 -
key
– 所要選擇的DynamicFrame
金鑰 (必要)。 -
transformation_ctx
– 用於識別狀態資訊的唯一字串 (選用)。
apply(cls, *args, **kwargs)
繼承自 GlueTransform
apply。
name(cls)
繼承自 GlueTransform
name。
describeArgs(cls)
繼承自 GlueTransform
describeArgs。
describeReturn(cls)
繼承自 GlueTransform
describeReturn。
describeTransform(cls)
繼承自 GlueTransform
describeTransform。
describeErrors(cls)
繼承自 GlueTransform
describeErrors。
describe(cls)
繼承自 GlueTransform
describe。