def kill_brackets(x):
"""Get rid of annoying brackets in numpy arrayss"""
x = x.replace("[[ ","")
x = x.replace(" ]]","")
x = x.replace("[[ ","")
x = x.replace(" ]]","")
x = x.replace("[[","")
x = x.replace("]]","")
x = x.replace("[ ","")
x = x.replace(" ]","")
x = x.replace("[ ","")
x = x.replace(" ]","")
x = x.replace("[","")
x = x.replace("]","")
return(x)
After Change
def kill_brackets(x):
"""Get rid of brackets and trailing whitespace in numpy arrays."""
return x.replace("[","").replace("]", "").strip()
def append_intercept(x):
"""
Appends an intercept term to the design matrix for a linear regression.