I have the following list that I convert to a numpy.array:
sells = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 599]
np_sells = np.array(sells)
print(np_sells)
>>
array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
599], dtype=int64)
I want to know the index of the first element that is different from 0, I try with np.nonzero() method and get this:
a = np.nonzero(np_sells)
print(a)
>> (array([13], dtype=int64),)
What I really need is that 13 to go look for that number in another list of dates (I am working on a time series), but if I try this code I keep getting the same error:
dates_list = ['01-07-2014','01-08-2014','01-09-2014','01-10-2014','01-11-2014','01-12-2014','01-01-2015','01-02-2015','01-03-2015','01-04-2015','01-05-2015','01-06-2015','01-07-2015','01-08-2015','01-09-2015','01-10-2015','01-11-2015','01-12-2015','01-01-2016','01-02-2016','01-03-2016','01-04-2016','01-05-2016','01-06-2016','01-07-2016']
dates_list[a]
>>> TypeError: list indices must be integers or slices, not tuple
I know it must be really simple but I'm stuck.