I am trying to loop over a dataframe. Especially through the date column so means for every date I get the x, y and z values for that date and fill it into my defined function. Somehow I am not sure how i can properly call it. My code looks like the following:
import pandas as pd
def calc_funct(x, y, z):
func = x*y*z
return func
if __name__ == '__main__':
df = pd.read_csv('C:/Data.csv')
for column in df:
results = calc_funct(df['x'], df['y'], df['z'])
print(result)
The input looks like the following:
date x y z
0 2017-11-11 18 17 7
1 2017-11-11 16 19 3
2 2017-11-11 13 14 2
3 2017-11-11 12 13 1
4 2017-11-11 11 12 9
5 2017-11-11 10 11 10
6 2017-11-11 21 10 11
7 2017-11-12 13 19 12
8 2017-11-13 18 17 12
9 2017-11-14 9 10 20
10 2017-11-15 2 20 13
11 2017-11-18 13 13 9
12 2017-11-19 18 14 16
13 2017-11-20 14 11 19
14 2017-11-21 18 15 19
For date 2017-11-11 I would calculate the values (e.g. add/subtract all values them at that date) and store it e.g. in a list. Then iterate over the next date 2017-11-12 etc...