lundi 2 avril 2018

Defining a variable between two points with a datetime pandas series

I have a pandas dataframe, and I want to calculate a variable based on certain hours of the day. I already pulled the hours as integers out of the datetime series. When i write my conditional statements between two hours and execute my script, I get the warning "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

When I put in any() or all() in my script, the script runs but it doesn't calculate the value between the two hours. I just get back a value that is not in the conditions. Can anyone help me out?

Here is my script so far

def func(hour):
    if ((hour > 8) and (hour < 17)):
        return g_night
    else:
        return g_day
g = func(hour)

Aucun commentaire:

Enregistrer un commentaire