Aug-07-2019, 01:35 PM
(Aug-07-2019, 01:26 PM)paul18fr Wrote:(Aug-07-2019, 01:12 PM)ThomasL Wrote: please explain the usage of ; at the end of each linehabit coming from Mathlab (BTW it has no consequence)
This is python and not javascript!
I didn't understand that you want to get the number of occurences of "...85" (i.e the dots AND 85)
yes, because the list is very long so I also cannot use the method of just counting the difference as suggested above for 1000 plus rows of time series data. To make it simpler, the list below as an example:
n = [0,1,1,1,1,2,2,2,85,85,85,80,80,80,0,1,1,1,2,2,2,85,85,85,80,80,80]
I tried to use the code below with the logic of first checking if the value is 85 and if the previous value is not 85 and the next value is the same as 85 then count 1. But I am getting an error; AttributeError: 'int' object has no attribute 'iloc'
this code does not include the counting part yet.
for i, x in enumerate(n): if x==85 and x.loc[i-1]!= 85 and x.iloc[i+1]==85: print(i)