0

I have to run a code which updates the details about 5 tables(table name, date, number of observations in the table on that date). The number of entries for these tables(A,B,C,D,E) are updated on a daily basis. The agenda is to create a history table which holds records date wise for all the tables. I made the code and need to apply the scheduler so that the code runs every 24 hrs. The problem is that I want to put only certain part of my code in scheduler and not the complete code. How do I do it ?

## History table which will only run at the start of the process data = [('A',len(A),t),('B',len(B),t),('C',len(C),t),('D',len(D),t),('E',len(E),t)] df = pd.DataFrame(data,columns=['Name','LENGTH','date']) df ## This code will run everyday and will merge with the history table import sched import time scheduler = sched.scheduler(time.time, time.sleep) def auto_table(): import datetime t= datetime.date.today()-datetime.timedelta(days=0) t data = [['A',len(A),t],['B',len(B),t],['C',len(C),t],['D',len(D),t], ['E',len(E),t]] df1 = pd.DataFrame(data,columns=['Name','LENGTH','date']) global df df=df.merge(df1,how='outer') return df print ('START:', time.time()) scheduler.enter(1, 1, auto_table()) scheduler.run() 

I got this error:

START: 1547819432.8968043 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-199-f7820889e2d5> in <module>() 22 scheduler.enter(1, 1, auto_table()) 23 ---> 24 scheduler.run() C:\ProgramData\Anaconda3\lib\sched.py in run(self, blocking) 152 delayfunc(time - now) 153 else: --> 154 action(*argument, **kwargs) 155 delayfunc(0) # Let other threads run 156 TypeError: 'DataFrame' object is not callable 
3
  • 1
    Please put code/output/large in code blocks. The editor has a button for it. Commented Jan 21, 2019 at 11:32
  • I am using Jupyter Notebooks. What shall I add in that ? Commented Jan 21, 2019 at 13:31
  • I meant in this question. Looks like deceze correct your issue with how the question was written. All should be good :) Commented Jan 21, 2019 at 16:47

1 Answer 1

1

https://github.com/kl09/py_scheduler Python Scheduler, check Read.me for example

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.