import yfinance as yf import pandas as pd import csv class price: def __init__(self, ticker): self.ticker = ticker company = yf.Ticker(self.ticker) price = company.history(period='max') price_df = pd.DataFrame(price) price_df.to_csv('test2.csv', index=False) l = ['AAPL', 'KO'] for item in l: price(item)
when I export or print
price_df I will only get the last entry in my list, i.e. only get "KO" price data without "AAPL" as well. The goal is to have "AAPL" price data directly followed by "KO" in one DataFrame. How would I do this?