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
db042190
Post Prodigy
Post Prodigy

python's yfinance returns data from command line but i dont even get a dataset in pbi

Hi , v-binbinyu shared this with us...   https://towardsdatascience.com/best-5-free-stock-market-apis-in-2019-ad91dddec984 .

 

I was able to list stock ticker MSFT history from my pc's command line but i show nothing (not even a dataset) when i go thru the same steps in setting up a pbi python connector.  Can someone help?

 

my script was entered in pbi as follows but even after reboot i couldnt get a dataset in pbi:

 

import yfinance as yf
msft = yf.Ticker("MSFT")
msft.history(period="max")

 

itrunsfromcommandline.pngnavigator shows nothing.png

 

 

 

1 ACCEPTED SOLUTION
db042190
Post Prodigy
Post Prodigy

i'm not sure if the history method can ever act in this capacity and i did see pbi alternatives that use web sources instead of python for this same purpose but this seems to work...i dont think dataset is a key word.  The last 2 statements apparently add columns to what the download method already offers.  I'll be looking up/for ways to make the download method show more tickers and the symbol itself rather than the hardcoded stock name.

 

import yfinance as yf

dataset=yf.download('MSFT','2010-01-01','2023-06-30')

dataset["Date"]=dataset.index

dataset["Stock"]="Microsoft"

 

finallygotadatasetinpbi.png

View solution in original post

2 REPLIES 2
db042190
Post Prodigy
Post Prodigy

the history method can do it too.  Had I coded my script like this, it would have worked too.  Notice an object (dataset2) is assigned/points at the results of the history method.

 

import yfinance as yf
msft = yf.Ticker("MSFT")
dataset2=msft.history(period="max")

db042190
Post Prodigy
Post Prodigy

i'm not sure if the history method can ever act in this capacity and i did see pbi alternatives that use web sources instead of python for this same purpose but this seems to work...i dont think dataset is a key word.  The last 2 statements apparently add columns to what the download method already offers.  I'll be looking up/for ways to make the download method show more tickers and the symbol itself rather than the hardcoded stock name.

 

import yfinance as yf

dataset=yf.download('MSFT','2010-01-01','2023-06-30')

dataset["Date"]=dataset.index

dataset["Stock"]="Microsoft"

 

finallygotadatasetinpbi.png

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.