How do I make it so that when I go through this loop, the data frame is updated each time with the new price data?
import time
import pandas as pd
import pycoingecko
cg = pycoingecko.CoinGeckoAPI()
for i in range(10):
df = pd.DataFrame(cg.get_coin_ticker_by_id(id='bitcoin').get('tickers'))
time.sleep(2)
You just creating another dataframe and dont keep information from the previous loop. You should concatenate dataframes.
Creating new dataframe each time:
Here list elements are dataframes.