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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Python data connection

Hi All,

do I need connect data via Python Script to be able to use them for visualisation by python?

All manuals I have seen are using data connected by python only. 

I have complex report with several kind of data source. Do I need to connect all sources via python which I want to use for python script visualization?

 

If not, how I can in python script for visualisation use data which has been connected in standard way (using top ribbon menu)?

4 REPLIES 4
ichavarria
Solution Specialist
Solution Specialist

You don't necessarily need to connect your data sources via Python in order to use them for visualization with Python in Power BI. Power BI supports a wide range of data sources that can be connected and used for visualization without needing to use Python to access the data.

 

If you have already connected your data sources in Power BI, you can use them directly in Python visualizations by using the pandas library in Python. The pandas library provides a way to read data from various sources, including CSV files, Excel files, SQL databases, and more.

 

Here's an example of how you can use pandas to read data from a CSV file and use it for visualization in a Python visualization in Power BI:

 

  1. Import the necessary libraries:

    import pandas as pd import matplotlib.pyplot as plt import seaborn as sns

  2. Read the data from the CSV file:

    df = pd.read_csv("data.csv")

  3. Create a visualization using the data:

    sns.set(style="darkgrid") plt.figure(figsize=(10,6)) sns.barplot(x="Category", y="Sales", data=df) plt.title("Sales by Category") plt.xlabel("Category") plt.ylabel("Sales") plt.show()

 

In this example, we're using pandas to read data from a CSV file named "data.csv". We then create a bar chart using the seaborn library and matplotlib library, and display it using plt.show().

 

You can use this approach to read data from any data source that pandas supports and use it for visualization in a Python visualization in Power BI. Keep in mind that if you have multiple data sources with different structures or schemas, you may need to do some data manipulation or transformation before you can use them together in a Python visualization.


Best regards, 

Isaac Chavarria 


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

Padycosmos
Solution Sage
Solution Sage

As I understand we need to import data from Python to Power BI and Then Create the Visualisation using Python script.

You can see a demo in this video: https://www.youtube.com/watch?v=k4GJu9Enb1g&list=PLApPcvU5-R24K3mbxORV7T3ckVLfDjmHF&index=17

v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

The Python script can get the data from the code return and in my research , it can also create Power BI visuals with Python.For more information, you can refer to :
Create Power BI visuals using Python in Power BI Desktop - Power BI | Microsoft Learn

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Anonymous
Not applicable

@v-yueyunzh-msftyou didn't answered on my question and an article on link doesn't describe data connected in standard way.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.