Q:

How to check if the signs of a Series conform to a given string of signs? 

For example I have a Series as below,
ts = pd. Series([-1,-2.4,5,6,7, -4, -8])

I would like to know if there is pythonic way to check the signs of ts against a list of signs, such as, 
sign = '++++---' # returns False

while
sign = '--+++--' # returns True

A:

This solution requires some numpy functions, but since you are using pandas for your data series, this is probably not an issue for you. 
import pandas as pd
import numpy as np

values = pd. Series([-1, -2.4, 5, 6, 7, -4, -8, 0])
sign_str = "--+++--0"

sign_map = {
    "+" : 1,
    "0" : 0,
    "-" : -1
}

expected_signs = list(map(sign_map.get, sign_str))
observed_signs = np.sign(values)
np.all(expected_signs == observed_signs)

