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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Multiple dataframes in python visual

Hello

I can't find any documentation on importing multiple dataframes into a python visual.

 

By default the python visual places all selected dimensions and measures together:

#dataset = pandas.DataFrame(dimension, measure, dimension2,measure2, dimension3, etc... )
 
I would like to import two separate dataframes so that each is evaluated indipendently from the other.
#dataset = pandas.DataFrame(dimension, measure )
#dataset2 = pandas.DataFrame(dimension2,measure2 )
I would then do some pandas transformation, merge them together and plot.
How do I do that?
 
Also question: why is the initial boilerplate commented out?
I can't understand how powerbi interprets that code since it's commented out.
 
Thank you
1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Anonymous,

A limitation of visuals (core, custom, R, Python or otherwise) is that they can only execute a single DAX query , and therefore only contain a single dataset, so it is not possible to use two independent data frames. The only way around this might be to to combine all the data as a single dataset and then process into independent data frames accordingly before you start doing your main body of work.

The boilerplate code is a series of comments informing you what pre-processing Power BI does to the dataset prior to the point where you add your code, as well as how to access the visual data (i.e. though the named dataset variable). If this were missing and you had not read the relevant documentation then it might not be clear how to proceed withough seeking information elsewhere. It's basically a succinct version of this section of the doc:

As you select or remove fields, supporting code in the Python script editor is automatically generated or removed.

Based on your selections, the Python script editor generates the following binding code.

  • The editor created a dataset dataframe, with the fields you added.
  • The default aggregation is: do not summarize.
  • Similar to table visuals, fields are grouped and duplicate rows appear only once.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

Hi @Anonymous,

A limitation of visuals (core, custom, R, Python or otherwise) is that they can only execute a single DAX query , and therefore only contain a single dataset, so it is not possible to use two independent data frames. The only way around this might be to to combine all the data as a single dataset and then process into independent data frames accordingly before you start doing your main body of work.

The boilerplate code is a series of comments informing you what pre-processing Power BI does to the dataset prior to the point where you add your code, as well as how to access the visual data (i.e. though the named dataset variable). If this were missing and you had not read the relevant documentation then it might not be clear how to proceed withough seeking information elsewhere. It's basically a succinct version of this section of the doc:

As you select or remove fields, supporting code in the Python script editor is automatically generated or removed.

Based on your selections, the Python script editor generates the following binding code.

  • The editor created a dataset dataframe, with the fields you added.
  • The default aggregation is: do not summarize.
  • Similar to table visuals, fields are grouped and duplicate rows appear only once.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Anonymous
Not applicable

Thank you Daniel

I was hoping the boilerplate would get executed at some point internally so I was trying to force two dataframes in it but now I understand it's really just documentation.

 

So I'm back to square one

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.

Top Kudoed Authors