Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to count a consecutive series of positive or negative values in a column in python

a = [0,0,1,1,1,0,0,1,0,1,1]
b = [0,0,0,0,0,0,0,0,0,0,0]

for i in range(len(a)):
    if a[i] == 1:
        b[i] = b[i-1] + 1
    else:
        b[i] = 0
Comment

PREVIOUS NEXT
Code Example
Python :: numpy reg ex delete words before a specific character 
Python :: connect two mathod to the same button in pyq5 
Python :: how to crack a 4 way handshake with python 
Python :: ORing two cv mat objects 
Python :: python ocr pdf dataframe 
Python :: islink(node1 node2) is used for 
Python :: how to put words into list 
Python :: pandas show head and tail 
Python :: python rename columns 
Python :: access matrix value opencv 
Python :: como fazer print no python 
Python :: mudopy 
Python :: python selenium not returning correct source 
Python :: bar chart with x-ticks 
Python :: how many perfect squared lie between 1 and 400 
Python :: aiml python install 
Python :: sequencia de fibonacci python 
Python :: how to check if a column exists before alter the table 
Python :: matplotlib FiveThirtyEight creating a signature 
Python :: how to make a square multicolor square spiral python 
Python :: trace table python 
Python :: get node name dynamo revit 
Python :: ~coinbase api 
Python :: how to run function when file is modified python 
Python :: how to convert nonetype to list in python 
Python :: str.format() 
Python :: Realtime-yahoo-stock_price 
Python :: FizzBuzz in Python Using itertools 
Python :: looping emails using a database with python code 
Python :: add Elements to Python list Using extend() method 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =