Semantic Link Functions - Validators
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
- breaking The broader 'semantic-link' meta-package (and 'semantic-link-sempy') has reported breaking compatibility with 'pandas >= 3.0', leading to 'AttributeError: 'types.SimpleNamespace' object has no attribute 'suffixes''. As 'semantic-link-functions-validators' integrates with 'FabricDataFrame' (a pandas subclass), this incompatibility may affect its usage if 'pandas 3.0+' is in the environment with older 'semantic-link' or 'sempy' versions.
- gotcha This library is primarily designed for use within Microsoft Fabric notebooks and leverages the `FabricDataFrame` structure and semantic link's environment. While the `FabricDataFrame` can be instantiated locally (as shown in the quickstart for demonstration), some functionalities, especially those involving metadata propagation or interaction with Power BI semantic models, might require a genuine Fabric environment for full operation and discovery of semantic functions.
- gotcha Authentication issues (403 errors) have been reported when using `sempy.fabric` functions, which `semantic-link-functions-validators` relies upon. This can stem from environment context or token acquisition problems within Fabric notebooks.
Install
-
pip install semantic-link-functions-validators
Imports
- FabricDataFrame
from sempy.fabric import FabricDataFrame
Quickstart
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}")