I have a giant array called AllDays storing datetime.
I generated an array which stores day of week information for each day.
I am trying to extract the weekends only from the original datetime array AllDays.
So, from the day of week I am trying the following:
DayOfWeek = np.asarray([x.weekday() for x in AllDays])
#AllDays stores datetime objects
ind = np.where(DayOfWeek == 0 or DayOfWeek == 6) #gives Error
I aim to use it as following to extract only the weekends:
weekends = AllDays[ind]
Error at line
ind = np.where(DayOfWeek == 0 or DayOfWeek == 6)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
weekend_indexes = (0, 6)and checkDayOfWeek in weekend_indexes. Then you'd have a single condition to put in yournp.where()ValueErrorcomes up frequently. It indicates that an array is being used in a context that expects a scalar True/False (e.g. theor).