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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
subhashree_r
Helper I
Helper I

Reg. Python script error

Hello all, 

      Iám trying to implement machine learning in power BI , While trying to run the python code at edit queries level , the below given error is being thrown , can anyone guide me with a possible solution :

Python code :

from pycaret.clustering import *
dataset = get_clusters(data = dataset)

 

Error generated:

DataSource.Error: ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\Users\subhashreer\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\__init__.py", line 55, in <module>
from pandas.core.api import (
File "C:\Users\subhashreer\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\api.py", line 29, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "C:\Users\subhashreer\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy

2 REPLIES 2
ibarrau
Super User
Super User

Hi. This might sound a stupid question but, is this code working outsite Power Bi? As far as I remember you have to specify the number of clusters.

I have found these articles. I hope they can help you:

https://towardsdatascience.com/how-to-implement-clustering-in-power-bi-using-pycaret-4b5e34b1405b

https://prog.world/how-to-implement-clustering-in-power-bi-using-pycaret/

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Hello @Anonymous, 

       The cluster number need not be specified because in the standard function, the cluster number is taken as four. There is a problem somewhere else.

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.