FormatCase 類別 - AWS Glue

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

FormatCase 類別

FormatCase 轉換會將資料欄中的每個字串變更為指定的案例類型。

範例

from pyspark.context import SparkContext from pyspark.sql import SparkSession from awsgluedi.transforms import * sc = SparkContext() spark = SparkSession(sc) datasource1 = spark.read.json("s3://${BUCKET}/json/zips/raw/data") try: df_output = data_cleaning.FormatCase.apply( data_frame=datasource1, spark_context=sc, source_column="city", case_type="LOWER" ) except: print("Unexpected Error happened ") raise

輸出

FormatCase 轉換會根據 `case_type="LOWER"` 參數,將 `city` 欄中的值轉換為小寫。產生的 `df_output` DataFrame 將包含來自原始 `datasource1` DataFrame 的所有資料欄,但 `city` 資料欄值為小寫。

方法

__call__(spark_context, data_frame, source_column, case_type)

FormatCase 轉換會將資料欄中的每個字串變更為指定的案例類型。

  • source_column – 現有資料欄的名稱。

  • case_type – 支援的案例類型為 CAPITALLOWERUPPER、、SENTENCE

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