I am trying to make a function to create a new column with the following parameters.
import pandas as pd
data = {'weekdaystart': ['Monday', 'Monday'], 'weekdayend': ['Monday', 'Tuesday'],'starthour': [7,21] ,'endhour':[15,7]}
dc = pd.DataFrame.from_dict(data)
def lol(dt,col1,col2,col3,col4):
for i in dt.index:
a = dt[col1].iloc[i]
b = dt[col2].iloc[i]
c = dt[col3].iloc[i]
d = dt[col4].iloc[i]
if a == b:
if 7 < c <= 15 and 7 < d <= 15:
return d - c
else:
return 0
else:
return
dc['Weekday_Day_hr'] = dc.apply(lol(dc,'weekdaystart','weekdayend','starthour','endhour'))
But I am getting 'int' object is not callable. The expected result for dc['Weekday_Day_hr'] the first row would be 15-7 and for the second row would be 0. I am not sure if I did the def lol wrong, or should I try with iterrows()?