a3 = [1, 2, 1, 1, 0, -3, -4, 7, 8, 9, 10, 0, -2, 0, 0, 1, 0, -3, 0, 5, 6, 7,
    -10]
s3 = numpy.sign(a3)
s3[s3 == 0] = -1
zero_crossings3 = numpy.where(numpy.diff(s3))[0]
print(s3)
print(zero_crossings3)
print(len(zero_crossings3))
Efficiently detect sign-changes in python