yfinance

Sort Columns by assigned column

Sort Columns by assigned column Question: I have a following code: import bs4 as bs import requests import yfinance as yf import datetime import pandas as pd import time starttimer = time.time() resp = requests.get(‘http://en.wikipedia.org/wiki/List_of_S%26P_500_companies’) soup = bs.BeautifulSoup(resp.text, ‘lxml’) table = soup.find(‘table’, {‘class’: ‘wikitable sortable’}) tickers = [] for row in table.findAll(‘tr’)[1:]: ticker = row.findAll(‘td’)[0].text …

Total answers: 2

Select specific column in Python dictionary?

Select specific column in Python dictionary? Question: I would like to select a specific field from a python dictionary. The following code produces a result of 152 lines, but I only want to select one line and output it as a dataframe. import pandas as pd from yahooquery import Ticker AAPL = Ticker(‘AAPL’) AAPL.earnings_trend Code …

Total answers: 2

pulling yFinance to pandas to_csv

pulling yFinance to pandas to_csv Question: I’m trying to pull information for 5y of ticker history(where applicable) from a series of stocks and save it to a csv so I only have to do this step once (can load the 5 year data locally and just update daily to it for the values I end …

Total answers: 1

YFinance_Can't get data from dictionary_Python_Jupyter notebook

YFinance_Can't get data from dictionary_Python_Jupyter notebook Question: This is my first experience in Python and Stackoverflow 🙂 I try to update my xls file with Portfolio using Yfinance. I’m interested in two parameters on each stock : current price and sector. I try to update my Pandas DataFrame using the code below. It works fine …

Total answers: 4

How to hide the index column of a pandas dataframe?

How to hide the index column of a pandas dataframe? Question: Help please, I need to delete the ‘date’ index column, or else ‘date’ will appear in the first column with the actions heat_ds = pd.DataFrame(columns=[‘PFE’,’GS’,’BA’,’NKE’,’V’,’AAPL’,’TSLA’,’NVDA’,’MRK’,’CVX’,’UNH’]) heat_ds[‘PFE’] = pfizer[‘Close’] heat_ds[‘GS’] = goldmans[‘Close’] heat_ds[‘BA’] = boeingc[‘Close’] heat_ds[‘NKE’] = nike[‘Close’] heat_ds[‘V’] = visa[‘Close’] heat_ds[‘AAPL’] = aaple[‘Close’] heat_ds[‘TSLA’] …

Total answers: 2

Inserting yfinance API data from Python into MYSQL Table

Inserting yfinance API data from Python into MYSQL Table Question: just after some help (I’m a python beginner so please excuse me). I have installed the yfinance api in python and extracted historic stock data using the following commands: import yfinance as yf fltdata = yf.download(tickers="FLT", start="2021-12-06", end="2022-12-06", period="1d") print (fltdata) Which gives me an …

Total answers: 1

Python – yfinance library JSONDecodeError when downloading

Python – yfinance library JSONDecodeError when downloading Question: I run import yfinance as yf df = yf.Ticker("NOK").history(start_date="2020-11-30", end_date="2021-09-30", interval="1h") which returns ————————————————————————— JSONDecodeError Traceback (most recent call last) <ipython-input-15-c5289e094c7b> in <module> 1 import yfinance as yf 2 —-> 3 df = yf.Ticker("NOK").history(start_date="2020-11-30", end_date="2021-09-30", interval="1h") D:ProgrammePythonAnacondalibsite-packagesyfinancebase.py in history(self, period, interval, start, end, prepost, actions, auto_adjust, back_adjust, …

Total answers: 1

DataFrame returns empty after .update()

DataFrame returns empty after .update() Question: I am trying to create a new DataFrame which contains a calculation from an original DF. To that purpose, I run a for loop with the calc for each column, but I am still getting the empty original DF and I don’t see where is the source of the …

Total answers: 1

Dataframe printed to terminal without print() command

Dataframe printed to terminal without print() command Question: I have written some code to download stockprices using Python. All Tickers (140+, e.g. BMW.DE) have no problems. I’m having issues with ‘CON.DE’. It won’t save to a .csv file and more peculiar it prints the dataframe to the terminal without there being a print() command. I’m …

Total answers: 1

Export Lastest Quarter yfinance Balance Sheet Results Into Single Excel Workbook?

Export Lastest Quarter yfinance Balance Sheet Results Into Single Excel Workbook? Question: The code below is what I have so far, thanks to Luis from my earlier question. The current code creates a separate worksheet for each ticker (and all quarters). Current results are pictured below. I would like to have one sheet with just …

Total answers: 1