You are on page 1of 1

import yfinance as yf

tsla = yf.Ticker("TSLA")

# get all stock info


tsla.info

# get historical market data


tsla_data = tsla.history(period="max")

tsla_data.head(n=5)

reset_index(inplace=True)

html_data = requests.get('https://cf-courses-data.s3.us.cloud-object-
storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0220EN-SkillsNetwork/labs/
project/revenue.htm').text
soup = BeautifulSoup(html_data, "lxml")
#Aplico filtro para seleccionar,localizar tablas y asigno valor a un objeto "table"
table=soup.find_all('tr')
tesla_revenue = pd.DataFrame(columns = ["Date", "Revenue"])
for row in soup.find('tbody').find_all('tr'):
col = row.find_all('td')
date = col[0].text
revenue = col[1].text

tesla_revenue = tesla_revenue.append({"Date":date, "Revenue":revenue},


ignore_index=True)
tesla_revenue["Revenue"] = tesla_revenue['Revenue'].str.replace(',|\$',"")
tesla_revenue.dropna(inplace=True)

tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != ""]


tesla_revenue.tail(n=5)

You might also like