I have a new question concerning filtering pandas in Python.
My original data frame, DF, looks like this
date currency 1Y 1Y1M 1Y2M 1Y3M 1Y4M
2013-09-25 EUR 0 0 0 0 0
2013-09-26 EUR 0 0 0 0 0
2013-09-27 EUR 0 0 0 0 0
2013-09-28 EUR 0 0 0 0 0
2013-09-29 EUR 0 0 0 0 0
2013-09-25 USD 0 0 0 0 0
2013-09-26 USD 0 -2 -4 -8 -10
2013-09-27 USD 0 -1 -1 -6 -1
2013-09-28 USD 0 -3 -6 -2 -6
2013-09-29 USD 0 -5 -1 -6 -7
What I would like to do, is to somehow filter this data on 'USD', and change signs to all available data matching the criteria. I want the original data to be changed (so not a copy), i.e. the resulting dataframe (i.e. DF) would be,
date currency 1Y 1Y1M 1Y2M 1Y3M 1Y4M
2013-09-25 EUR 0 0 0 0 0
2013-09-26 EUR 0 0 0 0 0
2013-09-27 EUR 0 0 0 0 0
2013-09-28 EUR 0 0 0 0 0
2013-09-29 EUR 0 0 0 0 0
2013-09-25 USD 0 0 0 0 0
2013-09-26 USD 0 2 4 8 10
2013-09-27 USD 0 1 1 6 1
2013-09-28 USD 0 3 6 2 6
2013-09-29 USD 0 5 1 6 7
I have tried using the function 'where' as so (with printing to see effect)
mask = DF['currency'].str.contains('USD')
print DF.ix[mask,'1Y1M']
DF.where(DF[~mask], -1 * DF,inplace=True)
print data_BBG.ix[mask,'1Y1M']
But the print-results show no effect.
Any insights would be great!