I want to make a conditional replacement based on the first index value in my pandas dataframe. If I have a dataframe such as:
from pandas import *
arrays = [['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'],
['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']]
tuples = zip(*arrays)
index = MultiIndex.from_tuples(tuples, names=['first','second'])
data = DataFrame(randn(8,2),index=index,columns=['c1','c2'])
I think I should be able to replace value in column via:
data.ix['bar']['c1'] = -999
But this returns the original dataframe, unchanged. Can anyone explain how this should be done and why my current method does not work?