embed power bi to jupyter notebook code example
Example: embedding power bi in jupyter notebook
# Install the package using pip
pip install powerbiclient
# Or if you use JupyterLab
pip install powerbiclient
jupyter labextension install @jupyter-widgets/jupyterlab-manager
# 1. Import Report class and models from the package
from powerbiclient import Report, models
# 2. Authenticate against Power BI using Azure AD
#Import the DeviceCodeLoginAuthentication class to authenticate against Power BI
from powerbiclient.authentication import DeviceCodeLoginAuthentication
#Initiate device authentication
device_auth = DeviceCodeLoginAuthentication()
# 3. Set the workspace ID and report ID you’d like to embed
group_id=""
report_id=""
# 4. Create an instance of Power BI report and load the report to the output cell
report = Report(group_id=group_id, report_id=report_id, auth=device_auth)
report