Johan Johan - 3 months ago 15
Python Question

Pandas dropna does not work as expected on a MultiIndex

I have a Pandas DataFrame with a multiIndex. The index consists of a date and a text string. Some of the values are NaN and when I use dropna(), the row disappears as expected. However, when I look at the index using df.index, the dropped dates are still there. This is problematic as when I use the to_panel function, the dropped dates reappear.

Am I using dropna incorrectly or how can I resolve this?

Answer

I think it is issue 2770.

And solution is decribe here.

index.get_level_values(level)
Comments