Semantic Link (SemPy)

0.14.0 · active · verified Wed Apr 15

Semantic Link, also known by its core Python library SemPy, facilitates seamless collaboration between data scientists and business analysts within Microsoft Fabric. It enables Python and Spark users in Synapse Data Science notebooks to connect directly to Power BI semantic models, access their underlying data, measures, and rich semantic information, eliminating the need to re-implement business logic. The library is actively developed, with version 0.14.0 as of the latest release, and is specifically designed for the Microsoft Fabric environment.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to list available semantic models (datasets) in your Microsoft Fabric workspace and then read a specific table from one of those models using the `sempy.fabric` module. This code should be executed within a Microsoft Fabric notebook.

import sempy.fabric as fabric

# List all semantic models (datasets) in the current workspace
df_datasets = fabric.list_datasets()
print("Available datasets:")
print(df_datasets.head())

# Assuming a dataset named 'Sales & Returns Sample' exists
# Read a specific table from a semantic model
df_customers = fabric.read_table(dataset="Sales & Returns Sample", table="Customer")
print("\nFirst 5 rows of the 'Customer' table:")
print(df_customers.head())

view raw JSON →