0
$\begingroup$

I have a csv file with five column data value.

five columns are ['A','B','C','D','time']

Here my 'D' column is the output column and 'A'is my first column.

Here I upload my coda and csv file.

data = pd.read_csv('data20.csv')
data = pd.DataFrame(data,columns=['time', 'A','B','C','D'])
for i in range(1, len(data)):
   data.loc[i+1,'A'] = data.loc[i, 'D'] + data.loc[i, 'B'] - data.loc[i, 'C']

my csv file ;

enter image description here

In my csv first row in A column 63 is represented and my output is 63 in D column. D column is my desired outputs. then in second row in A column its represented as 0. but I want to apply previous output value(63) into second row as A column input. Then that value will calculate by column B and reduce by C column then my desired output value is 60 represent in D column. So like this process will continue. So in A column 0 values replace by previous output value in D column.

Here I want to call that every hour this process continue. In my csv file till to 2 p.m output value is 72.

So then this 72 is will be the input of A column at 3p.m.then B and C column values will calculate or reduce using this formula will give the output for at 3.00 p.m.

So like this I want to find the value of D column at 4p.m, 5 p.m, 6 p.m till to 12 midnight and it will continous to next day. So I wrote the code and I ddn't have any idea to give time for this process. Can anyone help me to solve this problem?

$\endgroup$
0
$\begingroup$

you could do something like

import time
while True:
    <your code>
    time.sleep(3600)

this would execute your code every hour. I hope this answer your question.

$\endgroup$
  • $\begingroup$ I tried your code, but it's not running and it take so many time to give output. $\endgroup$ – user59020 Dec 11 '18 at 10:32
  • 1
    $\begingroup$ That's the point of the code, the line time.sleep(3600) pauses your code for 3600 seconds, I thought that's what you were looking for. $\endgroup$ – Robin Nicole Dec 11 '18 at 10:59
  • $\begingroup$ Actually that is not I was looking for, I'm going to predict next value in next hour using csv file with this code. $\endgroup$ – user59020 Dec 11 '18 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy