简体   繁体   中英

How to get Industry Data from Yahoo Finance using Python?

I currently have some tickers and data from yahoo finance gained through datareader for Python. I have got everything for the dataframe in relation to numbers except the industry from the profile of the ticker. I was wondering if there is any code that would work that would show the industry for the following ticker displayed through the profile page of yahoo?

Code Below:

import pandas_datareader.data as pdr

Tickers=['SBUX','TLRY']

SD='2005-01-31'

ED='2018-12-31'

TickerW=pdr.datareader(Tickers,'yahoo',SD,ED)

TickerW.head()

This cannot be done with pandas_datareader see here . You could use yfinance instead to get the sector.

as an example try:

import yfinance as yf

sbux = yf.Ticker("SBUX")
tlry = yf.Ticker("TLRY")

print(sbux.info['sector'])
print(tlry.info['sector'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM