0

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?

Carlo M
  • 13
  • 3
  • Does this answer your question? [Good alternative to Pandas .append() method, now that it is being deprecated?](https://stackoverflow.com/questions/70837397/good-alternative-to-pandas-append-method-now-that-it-is-being-deprecated) – Dash Dec 02 '22 at 23:14

1 Answers1

0
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
Carlo M
  • 13
  • 3
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 06 '22 at 08:00