Jupyter notebook is a very popular platform used by data scientist to analyze and built machine learning models. Its a commonly used quite a popular platform which provides lots of features to simplify and help in analyzing complex data structures and building data models for business need.
Integrating Power BI with Jupyter Notebook
Integration of Power BI provides the end user excellent reporting features for their analyzed data and provides an alternate way of reporting in addition to the Python Reporting Framework.
Getting Started
To start with you would require Python and Jupyter notebook installed on your machine. You would also need a Power BI report published on the Power Bi Service.
pip install powerbiclient
Once this is installed import the report class and models package using the following
from powerbiclient import Report, models
Now set two variables ie :group ID and report ID like shown below. Replace the group_id and report_id with your corresponding ids
group_id="f4cada80-87f1-4b6a-9f15-b1d74843b34b"
report_id="762f9384-71d3-4bda-9c4c-8973c9c0293f"
you can identify the Workspace ID(group ID) and report ID using the URL as shown below:
Next authenticate your device against Power BI using Azure AD using the following
from powerbiclient.authentication import DeviceCodeLoginAuthentication
device_auth = DeviceCodeLoginAuthentication()
Use the URL and code to sign in using your Power BI Credentials in order to authenticate .
Create an instance of the report and load the report
report = Report(group_id=group_id, report_id=report_id, auth=device_auth)
report
This will load your Power BI Report in the Jupyter notebook application.
I have used the Customer Profitability Sample Report provided by Microsoft to embed the report and Jupyter Notebook for Visual Studio Code .