I am trying to set or floor values which go beyond a defined threshold. I am using the .ix[] method for it. However, I am unable to get it done using the below is the code (python 2).
Please teach me why this is wrong & any other faster methods.
df = DataFrame({"v1" : np.random.randn(10), "v2" : np.random.randn(10), "v3" : [np.nan]*10})
print "pre floor"
print df
f_dict = {"v1": 0, "v2": 0}
#flooring value treatment
for key, val in f_dict.iteritems():
print df.ix[df[key]<val,key] = val
print df
#ERROR:
print df.ix[df[key]<val,key]=0
^
SyntaxError: invalid syntax