

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

# FillWithMode 類別
<a name="aws-glue-api-pyspark-transforms-FillWithMode"></a>

 `FillWithMode` 轉換會根據您指定的電話號碼格式，來格式化資料欄。您也可以指定和局中斷器邏輯，其中一些值是相同的。例如，請考慮下列值：`1 2 2 3 3 4`

 modeType `MINIMUM` 導致 `FillWithMode` 傳回 2 作為模式值。如果 modeType 為 `MAXIMUM`，則模式為 3。對於 `AVERAGE`，模式為 2.5。

## 範例
<a name="pyspark-FillWithMode-examples"></a>

```
from awsglue.context import *
from pyspark.sql import SparkSession
from awsgluedi.transforms import *

sc = SparkContext()
spark = SparkSession(sc)

input_df = spark.createDataFrame(
    [
        (105.111, 13.12),
        (1055.123, 13.12),
        (None, 13.12),
        (13.12, 13.12),
        (None, 13.12),
    ],
    ["source_column_1", "source_column_2"],
)

try:
    df_output = data_quality.FillWithMode.apply(
        data_frame=input_df,
        spark_context=sc,
        source_column="source_column_1",
        mode_type="MAXIMUM"
    )
    df_output.show()    
except:
    print("Unexpected Error happened ")
    raise
```

## Output
<a name="pyspark-FillWithMode-output"></a>

 指定的程式碼的輸出將是：

```
```
+---------------+---------------+
|source_column_1|source_column_2|
+---------------+---------------+
| 105.111| 13.12|
| 1055.123| 13.12|
| 1055.123| 13.12|
| 13.12| 13.12|
| 1055.123| 13.12|
+---------------+---------------+
```
```

 從 `awsglue.data\$1quality` 模組的 `FillWithMode` 轉換會套用至 `input\$1df` DataFrame。其會將 `source_column_1` 資料欄中的 `null` 值取代為該資料欄中非 Null 值的最大值 (`mode\$1type="MAXIMUM"`)。

 在此情況下，`source_column_1` 資料欄中的最大值為 `1055.123`。因此，`source_column_1` 中的 `null` 值會由輸出 DataFrame `df\$1output` 中的 `1055.123` 取代。

## 方法
<a name="aws-glue-api-pyspark-transforms-FillWithMode-_methods"></a>
+ [\$1\$1call\$1\$1](#aws-glue-api-pyspark-transforms-FillWithMode-__call__)
+ [apply](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-apply)
+ [name](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-name)
+ [describeArgs](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeArgs)
+ [describeReturn](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeReturn)
+ [describeTransform](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeTransform)
+ [describeErrors](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeErrors)
+ [describe](#aws-glue-api-crawler-pyspark-transforms-FillWithMode-describe)

## \$1\$1call\$1\$1(spark\$1context, data\$1frame, source\$1column, mode\$1type)
<a name="aws-glue-api-pyspark-transforms-FillWithMode-__call__"></a>

 `FillWithMode` 轉換會格式化資料欄中的字串大小寫。
+ `source_column` – 現有資料欄的名稱。
+ `mode_type` – 如何解析資料中的和局值。此值必須是 `MINIMUM`、`NONE`、`AVERAGE` 或 `MAXIMUM` 之一。

## apply(cls, \$1args, \$1\$1kwargs)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-apply"></a>

繼承自 `GlueTransform` [apply](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-apply)。

## name(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-name"></a>

繼承自 `GlueTransform` [name](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-name)。

## describeArgs(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeArgs"></a>

繼承自 `GlueTransform` [describeArgs](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeArgs)。

## describeReturn(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeReturn"></a>

繼承自 `GlueTransform` [describeReturn](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeReturn)。

## describeTransform(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeTransform"></a>

繼承自 `GlueTransform` [describeTransform](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeTransform)。

## describeErrors(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-describeErrors"></a>

繼承自 `GlueTransform` [describeErrors](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeErrors)。

## describe(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-FillWithMode-describe"></a>

繼承自 `GlueTransform` [describe](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describe)。