Here is my code
dataframe = pd.DataFrame(columns = my_columns)
for stock in stocks['Ticker'][:1]:
api_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote/?token={IEX_CLOUD_API_TOKEN}'
data = requests.get(api_url).json()
dataframe = dataframe.append(
pd.Series([stock, data['latestPrice'], marketCap/1000000000000],
index = my_columns),
ignore_index = True
)
dataframe
Returns this BUT!
Ticker | Stock Price | Market Cap |
---|---|---|
A | 153.57 | 2.37218 |
Also returns: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. dataframe = dataframe.append(
I understand I want to make dataframe a list but how do I parse through the Series?
dataframe = pd.DataFrame(columns = my_columns)
for stock in stocks['Ticker'][:1]:
api_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote/?token={IEX_CLOUD_API_TOKEN}'
data = requests.get(api_url).json()
new_row = pd.DataFrame(
[
[stock, data["latestPrice"], marketCap / 1000000000000]
],
columns=my_columns
)
dataframe = pd.concat([dataframe, new_row], ignore_index = True)
dataframe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.