Livio/ March 24, 2019/ Python/ 1 comments

When you need to download financial data to use into Power BI, searching for the right website or API can be a daunting task. Luckily, thanks to Python and its support into Power BI, it is possible to download stock data effortlessly. 

Download Python

I am assuming the reader has already Python installed, if not you can head over to: and download the latest version. Python makes it easy to perform many transformations which are not yet supported in Power Query, like for instance the use of Regular Expressions. 

As a code editor, you can download Visual Studio Code:

Download Pandas

Learning Pandas is a must if you are serious about doing Data Analysis with Python. No specific knowledge is required from you in order to benefit from this post, but I highly recommend you to look into it. After having installed Python, open the cmd.exe and type:

pip install pandas

once it has been installed, type:

pip install pandas_datareader

You can find how to set up Power BI to use Python in the following article:

Download Stock Data

Now that we’re done with the boring stuff, let’s download some stock data. Let’s say we wanted February 2019 stock data of Microsoft, Apple and Amazon. This becomes really easy using pandas_datareader. The Python script we will run is the following:

 Open Power BI, go to Get Data, then choose Other and then Python Script:

Python Script Power BI

Python Script Power BI

Python Script Power BI

Python Script Power BI

Once you click OK and let the script run, you will have stock data available in the Power Query editor:

Python Script Power BI

Python Script Power BI

you now just need to expand the table and done! 

1 Comment

  1. Hello, How we can import the data for ALL ‘symbols’ ?

Leave a Comment

Your email address will not be published. Required fields are marked *