For me, the following snippet leaves the NaN value as NaN:
import pandas
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [('eyes', 'left'), ('eyes', 'right'), ('ears', 'left'), ('ears', 'right')]
events = {('eyes', 'left'): a, ('eyes', 'right'): b, ('ears', 'left'): c, ('ears', 'right'): d}
multiind = pandas.MultiIndex.from_tuples(tuples, names=['part', 'side'])
zed = pandas.DataFrame(events, index=['a', 'b'], columns=multiind)
zed['eyes']['right'].fillna(value=555, inplace=True)
I get:
part eyes ears
side left right left right
a 12 123 1234 12345
b 23 NaN 2345 23456
If I run this with inplace
set to False, the returned Series has replaced NaN
with 555. I could use this work-around, but on the one hand, if it's a bug I want to report it, and on the other hand, even the work-around doesn't work for my actual application.
So the question is whether I misunderstand fillna()
or this is a bug. Thanks!
Edit: I'm using pandas 0.12.0, numpy 1.8.0, and python 2.7.5 on openSUSE 13.1.