1
import time
import pandas as pd
while True:
  df = pd.read_json('https://forex.1forge.com/1.0.3/quotes?pairs=EURUSD,EURJPY,GBPUSD,USDCAD,GBPJPY,USDJPY,AUDUSD,&api_key=KEY')
  df = df.pivot_table(['price'], ['timestamp'], 'symbol')
  print (df)
  time.sleep(60) 

Is there a simply way to, instead of the update happening every 60seconds with the sleep function, be exactly on the minute? Also, the pivot_table function sets the symbol pairs as the columns and has the index or rows set at time which is what i want to have happen, but now, when the next row is added (after the sleep 60) there is still the column names. Rather, i would like to have the appending row be under the subsequent row and not the columns title.

Noob74
  • 65
  • 7
  • 1
    Possible duplicate of [How do I get a Cron like scheduler in Python?](https://stackoverflow.com/questions/373335/how-do-i-get-a-cron-like-scheduler-in-python) – Alessandro Da Rugna Nov 02 '18 at 22:00

1 Answers1

0

I believe that schedule does this: https://schedule.readthedocs.io/en/stable/, and if I'm not mistaken, so do cronjobs. Some examples of schedule here: https://www.programcreek.com/python/example/82317/schedule.every

Edit: yes here the maintainer of schedule describes how it can be used as a crontab -- How do I get a Cron like scheduler in Python?

Charles Landau
  • 4,187
  • 1
  • 8
  • 24