Skip to content

Commit 9d2d4bf

Browse files
committed
BUG: clean NAs in DataFrame.boxplot, close #1506
1 parent 87d6da1 commit 9d2d4bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/tools/plotting.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas.util.decorators import cache_readonly
88
import pandas.core.common as com
99
from pandas.core.index import Index, MultiIndex
10-
from pandas.core.series import Series
10+
from pandas.core.series import Series, remove_na
1111
from pandas.tseries.index import DatetimeIndex
1212
from pandas.tseries.period import PeriodIndex
1313
from pandas.tseries.frequencies import get_period_alias, get_base_alias
@@ -1007,7 +1007,7 @@ def boxplot(data, column=None, by=None, ax=None, fontsize=None,
10071007
def plot_group(grouped, ax):
10081008
keys, values = zip(*grouped)
10091009
keys = [_stringify(x) for x in keys]
1010-
ax.boxplot(values, **kwds)
1010+
ax.boxplot(remove_na(values), **kwds)
10111011
if kwds.get('vert', 1):
10121012
ax.set_xticklabels(keys, rotation=rot, fontsize=fontsize)
10131013
else:
@@ -1043,7 +1043,8 @@ def plot_group(grouped, ax):
10431043

10441044
# Return boxplot dict in single plot case
10451045

1046-
bp = ax.boxplot(list(data[cols].values.T), **kwds)
1046+
clean_values = [remove_na(x) for x in data[cols].values.T]
1047+
bp = ax.boxplot(clean_values, **kwds)
10471048
if kwds.get('vert', 1):
10481049
ax.set_xticklabels(keys, rotation=rot, fontsize=fontsize)
10491050
else:

0 commit comments

Comments
 (0)