{"id":3270,"library":"semantic-link-sempy","title":"Semantic Link for Microsoft Fabric (SemPy)","description":"Semantic link connects Microsoft Fabric's Power BI semantic models with data science tools. SemPy is the Python library that is part of semantic link, providing functionalities to analyze and manipulate data from Power BI models directly within notebooks. It integrates deeply with Fabric DataFrames and allows for tasks like listing Power BI items, reading tables, and calculating measures. The current version is 0.14.0, and it's actively developed by Microsoft.","status":"active","version":"0.14.0","language":"en","source_language":"en","source_url":"https://aka.ms/semantic-link-docs","tags":["microsoft fabric","power bi","semantic link","data science","notebooks","dataframe"],"install":[{"cmd":"pip install semantic-link-sempy","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core data structure (FabricDataFrame extends pandas.DataFrame)","package":"pandas","optional":false},{"reason":"Numerical operations, commonly used with pandas","package":"numpy","optional":false},{"reason":"Efficient data transfer and serialization","package":"pyarrow","optional":false},{"reason":"Microsoft Authentication Library for Python (for authentication to Fabric)","package":"msal","optional":false},{"reason":"Azure authentication client library (used for Fabric connectivity)","package":"azure-identity","optional":false}],"imports":[{"note":"FabricDataFrame is part of the 'fabric' submodule, not directly under 'sempy'.","wrong":"from sempy.dataframe import FabricDataFrame","symbol":"FabricDataFrame","correct":"from sempy.fabric import FabricDataFrame"},{"note":"Functions interacting with Fabric entities are typically found in the 'sempy.fabric' module.","wrong":"import sempy.list_workspaces","symbol":"list_workspaces","correct":"from sempy.fabric import list_workspaces"},{"note":"Data reading functions for Fabric are in 'sempy.fabric'.","wrong":"from sempy.data import read_table","symbol":"read_table","correct":"from sempy.fabric import read_table"}],"quickstart":{"code":"import pandas as pd\nfrom sempy.fabric import FabricDataFrame, list_workspaces\n\n# Create a sample pandas DataFrame\ndf_pd = pd.DataFrame({\n    'ID': [1, 2, 3],\n    'Value': [100, 200, 150]\n})\n\n# Convert a pandas DataFrame to a FabricDataFrame\ndf_sempy = FabricDataFrame(df_pd)\nprint(\"--- FabricDataFrame created ---\")\nprint(df_sempy.head())\nprint(f\"Type: {type(df_sempy)}\\n\")\n\n# Attempt to list Fabric workspaces\n# This function (and most of sempy.fabric) requires an active Microsoft Fabric notebook environment\n# and an authenticated session to execute successfully.\nprint(\"--- Attempting to list Fabric workspaces ---\")\ntry:\n    workspaces = list_workspaces()\n    print(f\"Successfully listed {len(workspaces)} workspaces.\")\n    if workspaces:\n        print(f\"First workspace: {workspaces[0]['display_name']}\")\nexcept Exception as e:\n    print(f\"Failed to list workspaces. This is expected if not running in a Fabric notebook or without proper authentication.\\nError: {e}\")","lang":"python","description":"This quickstart demonstrates how to create a `FabricDataFrame` from a standard pandas DataFrame. It then attempts to use `sempy.fabric.list_workspaces()` to show interaction with Microsoft Fabric. Note that most `sempy.fabric` functions require execution within a Microsoft Fabric notebook environment with an authenticated session to function correctly."},"warnings":[{"fix":"Run your SemPy code in a Microsoft Fabric notebook for full functionality. Ensure your environment has the necessary authentication configured if attempting to use outside Fabric.","message":"SemPy is primarily designed for and best utilized within Microsoft Fabric notebooks. Running its Fabric-specific functionalities (e.g., `sempy.fabric` functions) outside of this environment will typically fail due to authentication or environment dependencies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand that SemPy's strength lies in its integration with Power BI semantic models. For general data tasks, consider using pandas directly or other libraries.","message":"The library primarily interacts with Power BI semantic models and their underlying data. It's not a general-purpose data manipulation library for arbitrary data sources, although it can work with pandas DataFrames as an entry point.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin your `semantic-link-sempy` version in your `requirements.txt` (`semantic-link-sempy==0.14.0`) and thoroughly test your code after any upgrades.","message":"As a pre-1.0 library (version 0.x.x), SemPy's API might experience breaking changes between minor versions. Always check the official documentation or release notes when upgrading.","severity":"breaking","affected_versions":"All 0.x.x versions"},{"fix":"Ensure your Python environment is version 3.10 or higher. Upgrade your Python interpreter if necessary.","message":"SemPy requires Python 3.10 or newer. Using older Python versions will result in installation or runtime errors.","severity":"gotcha","affected_versions":"<0.14.0 (requires >=3.10)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}