0

Whenever I run this code I get:

The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. What should I do to make the code run with concat?

final_dataframe = pd.DataFrame(columns = my_columns)
for symbol in stocks['Ticker']:
    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)
Sasha Cotrut
  • 1
  • 1
  • 2

1 Answers1

0

See this release note

or from another post:

"Append is the specific case(axis=0, join='outer') of concat" link

The changes in your code should be: (changed the pd.Series to variable just for presentation)

s = pd.Series([symbol, data['latestPrice'], data['marketCap'], 'N/A'], index = my_columns)
final_dataframe = pd.concat([final_dataframe, s], ignore_index = True)
Rabinzel
  • 7,757
  • 3
  • 10
  • 30