cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Python script error:"the preview for section 1/query1/source doesn't exist"

Hi,

When I tryto run this simple python script in power bi it throws this error " the preview for section 1/query1/source doesn't exist"

 

import pandas as pd
data = [['Alex',10],['Bob',12],['Clarke',13]]
df = pd.DataFrame(data,columns=['Name','Age'],dtype=float)
print (df)

How to fix this?
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Python script error:"the preview for section 1/query1/source doesn't exist"

Hi @ahmedidris ,

 

I am asssuming that you are following the below link to run this pythin script:

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts

 

I tried doing same and I can successfully run the script in python editor:

pythont.png

 

Also, make sure your Python home directory path is defined correctly in Power BI Desktop:

Pragati11_0-1596805659191.png

 

Thanks,

Pragati





If this helps, Appreciate a KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




View solution in original post

3 REPLIES 3
Highlighted
Super User II
Super User II

Re: Python script error:"the preview for section 1/query1/source doesn't exist"

Hi @ahmedidris ,

 

I am asssuming that you are following the below link to run this pythin script:

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts

 

I tried doing same and I can successfully run the script in python editor:

pythont.png

 

Also, make sure your Python home directory path is defined correctly in Power BI Desktop:

Pragati11_0-1596805659191.png

 

Thanks,

Pragati





If this helps, Appreciate a KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




View solution in original post

Highlighted
Resolver II
Resolver II

Re: Python script error:"the preview for section 1/query1/source doesn't exist"

Hi @ahmedidris ,

 

Can you show the M code?

I tried blank query, it worked well

 

let
    Source = Python.Execute("import pandas as pd#(cr)#(lf)data = [['Alex',10],['Bob',12],['Clarke',13]]#(cr)#(lf)df = pd.DataFrame(data,columns=['Name','Age'],dtype=float)#(cr)#(lf)print (df)")
in
    Source
Highlighted
Super User IV
Super User IV

Re: Python script error:"the preview for section 1/query1/source doesn't exist"

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors