wesm/pandas — Issue #691: assignment with ix and mixed dtypes
Author: jseabold
Created: 2012-01-26 18:34:16+00:00
State: open

data = {"title" : ['foobar','bar','foobar'] + ['foobar'] * 17 , "cruft" : np.random.random(20)}

df = pandas.DataFrame(data)

ix = df[df['title'] == 'bar'].index

# this doesn't work with a list of variables
df.ix[ix, ['title']] = 'foobar'
df.ix[ix, ['cruft']] = 0

print df

# but this does
df.ix[ix, 'title'] = 'foobar'
df.ix[ix, 'cruft'] = 0

print df