Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Using Power BI and Python for Data Science - statsmodels.api

Hi all,

 

I'm trying to use Power BI and Python to get a multivariate regression model built in Power BI Desktop. Using Python, I've imported the following packages to get started: pandas, numpy, matplotlib, statsmodels

 

Let's assume two independent variables (X1 and X2) and 1 dependent variable Y. 

 

When using Python, I've used this script:

 

import pandas as pd

import numpy as np

import matplotlib as plt

import statsmodels.api as sm

dataframe = pandas.DataFrame["X1 data", "X2 data", "Y data"]

 

X1 = dataframe["Name of X1 variable"]

X2 = dataframe["Name of X2 variable"]

Y = dataframe["Name of Y variable"]

model = sm.OLS(Y, X)

results = model.fit()

print(results.summary())

 

Which creates the image <here> , but the command doesn't work in Power BI. Does anyone have any ideas? 

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have you defined values to your variable?What is the error returned?

Here is the reference you can refer to.

 

 

 

Best Regards,
Kelly
 
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Super User
Super User

First thing I would check is if all of those packages are supported in Power BI. Also, define "does not work", do you get an error, blank screen, Power BI crashes and burns?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.