Forum Discussion
Collecting data (not visual) outputs from Python
- 7 years ago
Hi sfmike99
when you open a Query in the query editor you can choose Python script in the Transform tab (on the far right).
The DataFrame passed to Python is named 'dataset' and it is the table of the preceding query step. You can apply transofmrations to this DataFrame within Python by inputting the code and after you click ok you will see different DataFrames available for expansion, normally here you'd expand only the dataframe you actually want to return. Let me know if you need me to post pictures which could make it more clear
- 7 years ago
sfmike99 yes all the Drataframes should be visible after the script is run. You should have as many rows as dataframes created by your code. Normally then you'd filter by just the one you'd want to expand and then expand it
That works - thanks for helping me get my head around it!
Can I generate a new dataframe and pass it back to Power BI? For example, if I want to create a summary table of scores?
I can create a new table in the Python script without errors:
newtable = dataset[('ROUND')]
But I think I should see that table in the pulldown after the script executes right?
sfmike99 yes all the Drataframes should be visible after the script is run. You should have as many rows as dataframes created by your code. Normally then you'd filter by just the one you'd want to expand and then expand it
- sfmike997 years ago
Advocate II
That works! I forgot the double brackets in the Python script: newtable = dataset[['ROUND']]
Way cool...