3

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()
recurseuntilfor
  • 2,293
  • 1
  • 12
  • 17
Kani S
  • 73
  • 1
  • 1
  • 7

1 Answers1

7

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'])
recurseuntilfor
  • 2,293
  • 1
  • 12
  • 17
  • 1
    Thank you for the help! Much Appreciated! Just a newbie to coding lol :) – Kani S Nov 28 '19 at 03:56
  • 1
    This is exactly what I am looking for. This is the Nth time I have to find this out, yahoo kept changing and deprecating their APIs! – kawingkelvin Aug 25 '21 at 22:31