FormatPhoneNumber class - Amazon Glue
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

FormatPhoneNumber class

The FormatPhoneNumber transform returns a column in which a phone number string is converted into a formatted value.

Example

from pyspark.context import SparkContext from pyspark.sql import SparkSession from awsgluedi.transforms import * sc = SparkContext() spark = SparkSession(sc) input_df = spark.createDataFrame( [ ("408-341-5669",), ("4083415669",) ], ["phone"], ) try: df_output = column_formatting.FormatPhoneNumber.apply( data_frame=input_df, spark_context=sc, source_column="phone", default_region="US" ) df_output.show() except: print("Unexpected Error happened ") raise

Output

The output will be:

``` +---------------+ | phone| +---------------+ |(408) 341-5669| |(408) 341-5669| +---------------+ ```

The FormatPhoneNumber transformation takes the `source_column` as `"phone"` and the `default_region` as `"US"`.

The transformation successfully formats both phone numbers, regardless of their initial format, to the standard US format `(408) 341-5669`.

Methods

__call__(spark_context, data_frame, source_column, phone_number_format=None, default_region=None, default_region_column=None)

The FormatPhoneNumber transform returns a column in which a phone number string is converted into a formatted value.

  • source_column – The name of an existing column.

  • phone_number_format – The format to convert the phone number to. If no format is specified, the default is E.164, an internationally-recognized standard phone number format. Valid values include the following:

    • E164 (omit the period after E)

  • default_region – A valid region code consisting of two or three uppercase letters that specifies the region for the phone number when no country code is present in the number itself. At most, one of defaultRegion or defaultRegionColumn can be provided.

  • default_region_column – The name of a column of the advanced data type Country. The region code from the specified column is used to determine the country code for the phone number when no country code is present in the number itself. At most, one of defaultRegion or defaultRegionColumn can be provided.

apply(cls, *args, **kwargs)

Inherited from GlueTransform apply.

name(cls)

Inherited from GlueTransform name.

describeArgs(cls)

Inherited from GlueTransform describeArgs.

describeReturn(cls)

Inherited from GlueTransform describeReturn.

describeTransform(cls)

Inherited from GlueTransform describeTransform.

describeErrors(cls)

Inherited from GlueTransform describeErrors.

describe(cls)

Inherited from GlueTransform describe.