Semantic Link Functions - Validators

0.14.0 · active · verified Wed Apr 15

Semantic Link Functions - Validators is a Python library that extends Microsoft FabricDataFrames with semantic validation capabilities. It provides built-in functions for validating common data types such as email addresses and credit card numbers, leveraging the underlying 'validators' Python package. This library is part of the broader Microsoft Fabric semantic link ecosystem, enabling enhanced data quality within data science workflows in Fabric notebooks. It is actively maintained, with the current version being 0.14.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `semantic-link-functions-validators` to validate email addresses and credit card numbers within a `FabricDataFrame`. The validation functions (`is_email`, `is_credit_card`) are called directly as methods on the DataFrame series. This example is designed for use within a Microsoft Fabric notebook environment where `FabricDataFrame` is available and semantic link is active.

import pandas as pd
from sempy.fabric import FabricDataFrame

# NOTE: This code is intended to be run within a Microsoft Fabric notebook
# where semantic link is initialized. Running outside might require additional setup.
# For demonstration, we simulate a FabricDataFrame.

try:
    df = FabricDataFrame({
        'email_column': ['test@example.com', 'invalid-email', 'another@domain.co'],
        'cc_number': ['1234-5678-9012-3456', '1111-2222-3333', '4567-8901-2345-6789']
    })
    
    # Apply semantic validation functions directly to the DataFrame columns
    df['is_valid_email'] = df['email_column'].is_email()
    df['is_valid_cc'] = df['cc_number'].is_credit_card()
    
    print(df)
    
except ImportError:
    print("Please ensure 'semantic-link-functions-validators' and 'sempy' are installed.")
    print("Also, consider running this in a Microsoft Fabric environment for full functionality.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →