Semantic Link Functions for Phone Numbers

0.14.0 · active · verified Wed Apr 15

This library integrates the `phonenumbers` package with Semantic Link, enabling validation and enrichment of phone numbers within Microsoft Fabric DataFrames (FabricDataFrames). It simplifies operations on phone number columns for data quality and analysis, adding columns indicating validity, type, and various formats. The current version is 0.14.0, and it appears to follow the active release cadence of the broader `semantic-link-functions` project.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `FabricDataFrame` and use `validate_phone_number` to process a column containing phone numbers. The function enriches the DataFrame by adding several new columns with validation results and formatted phone numbers, such as `phone_is_valid` and `phone_e164_format`.

import pandas as pd
from sempy.fabric import FabricDataFrame # sempy is a required dependency for FabricDataFrame
from semantic_link_functions_phonenumbers import validate_phone_number

# In a real Microsoft Fabric environment, a FabricDataFrame 
# would typically be loaded from a Lakehouse table or similar source.
# For demonstration, we create one from a pandas DataFrame.
data = {'phone': ['+12065550100', '123-456-7890', 'invalid phone number']}
df = FabricDataFrame(pd.DataFrame(data))

# Validate phone numbers in the 'phone' column
# The function adds new columns (e.g., '_is_valid', '_number_type', '_e164_format')
df_validated = validate_phone_number(df, 'phone')

print("Original DataFrame:\n", df)
print("\nValidated DataFrame (selected columns):\n")
print(df_validated[['phone', 'phone_is_valid', 'phone_number_type', 'phone_e164_format']].head())

# Example of filtering invalid numbers
# print(df_validated[~df_validated['phone_is_valid']])

view raw JSON →