I am scraping this website (https://www.coingecko.com/en/coins/recently_added?page=1) using Pandas df. I want to get a snapshot of the coins and price and then get another snapshot of the coins and price 10 seconds later to see whether a coin has moved at price. Here is the code that I am using to do this:
import pandas as pd
import requests
import time
url = "https://www.coingecko.com/en/coins/recently_added?page=1"
df = pd.read_html(requests.get(url).text, flavor="bs4")
df = pd.concat(df).drop(["Unnamed: 0", "Unnamed: 1"], axis=1)
# print(df.head)
df_first = df[['Coin', 'Price']]
time.sleep(10)
url = "https://www.coingecko.com/en/coins/recently_added?page=1"
df = pd.read_html(requests.get(url).text, flavor="bs4")
df = pd.concat(df).drop(["Unnamed: 0", "Unnamed: 1"], axis=1)
df_last = df[['Coin', 'Price']]
df_merged = df_first.merge(df_last, left_on=['Coin'], right_on=['Coin'])
df_merged.set_index(['Coin'], inplace=True)
df_merged['pct_change'] = df_merged[['Price_x','Price_y']].pct_change(axis=1)['Price_y']
df_merged['greater_than_1'] = df_merged['pct_change'] > 10.00
print(df_merged)
When I run the code I am getting the error
TypeError: unsupported operand type(s) for /: 'str' and 'str'
not sure why. Any help welcome