I am trying to use concat function instead of append to produce the same output from this block of code:
final_dataframe = pd.DataFrame(columns = my_columns)
for symbol in stocks['Ticker'][:5]:
api_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote?token={IEX_CLOUD_API_TOKEN}'
data = requests.get(api_url).json()
final_dataframe = final_dataframe.append(
pd.Series([symbol,
data['latestPrice'],
data['marketCap'],
'N/A'],
index = my_columns),
ignore_index = True)
The output is this:
Ticker Stock_price Market_capitalization Number_of_shares_to_buy
0 A 144.3 42532431075 N/A
1 AAL 17.16 11068908461 N/A
2 AAP 210.74 12880265047 N/A
3 AAPL 167.43 2762301276735 N/A
4 ABBV 164.5 287271211810 N/A