Closed
Description
Very much an edge case:
In [17]: df = pd.DataFrame(np.random.randn(100, 4))
In [18]: df.loc[:, 0] = np.nan
In [19]: df.plot(kind='box')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-19-06443674b77d> in <module>()
----> 1 df.plot(kind='box')
/Users/tom/Envs/py3/lib/python3.4/site-packages/pandas/pandas/tools/plotting.py in plot_frame(frame, x, y, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, style, title, xlim, ylim, logx, logy, xticks, yticks, kind, sort_columns, fontsize, secondary_y, layout, **kwds)
2362 secondary_y=secondary_y, layout=layout, **kwds)
2363
-> 2364 plot_obj.generate()
2365 plot_obj.draw()
2366 return plot_obj.result
/Users/tom/Envs/py3/lib/python3.4/site-packages/pandas/pandas/tools/plotting.py in generate(self)
913 self._compute_plot_data()
914 self._setup_subplots()
--> 915 self._make_plot()
916 self._add_table()
917 self._make_legend()
/Users/tom/Envs/py3/lib/python3.4/site-packages/pandas/pandas/tools/plotting.py in _make_plot(self)
2140 kwds = self.kwds.copy()
2141
-> 2142 ret, bp = plotf(ax, y, column_num=0, **kwds)
2143 self.maybe_color_bp(bp)
2144 self._return_obj = ret
/Users/tom/Envs/py3/lib/python3.4/site-packages/pandas/pandas/tools/plotting.py in plotf(ax, y, column_num, **kwds)
2059 else:
2060 y = remove_na(y)
-> 2061 bp = ax.boxplot(y, **kwds)
2062
2063 if self.return_type == 'dict':
/Users/tom/Envs/py3/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/axes/_axes.py in boxplot(self, x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap, usermedians, conf_intervals, meanline, showmeans, showcaps, showbox, showfliers, boxprops, labels, flierprops, medianprops, meanprops, capprops, whiskerprops, manage_xticks)
3043 """
3044 bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
-> 3045 labels=labels)
3046 if flierprops is None:
3047 flierprops = dict(sym=sym)
/Users/tom/Envs/py3/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/cbook.py in boxplot_stats(X, whis, bootstrap, labels)
1963
1964 # medians and quartiles
-> 1965 q1, med, q3 = np.percentile(x, [25, 50, 75])
1966
1967 # interquartile range
/Users/tom/Envs/py3/lib/python3.4/site-packages/numpy/lib/function_base.py in percentile(a, q, axis, out, overwrite_input)
2818 axis = 0
2819
-> 2820 return _compute_qth_percentile(sorted, q, axis, out)
2821
2822 # handle sequence of q's without calling sort multiple times
/Users/tom/Envs/py3/lib/python3.4/site-packages/numpy/lib/function_base.py in _compute_qth_percentile(sorted, q, axis, out)
2824 if not isscalar(q):
2825 p = [_compute_qth_percentile(sorted, qi, axis, None)
-> 2826 for qi in q]
2827
2828 if out is not None:
/Users/tom/Envs/py3/lib/python3.4/site-packages/numpy/lib/function_base.py in <listcomp>(.0)
2824 if not isscalar(q):
2825 p = [_compute_qth_percentile(sorted, qi, axis, None)
-> 2826 for qi in q]
2827
2828 if out is not None:
/Users/tom/Envs/py3/lib/python3.4/site-packages/numpy/lib/function_base.py in _compute_qth_percentile(sorted, q, axis, out)
2854 # Use add.reduce in both cases to coerce data type as well as
2855 # check and use out array.
-> 2856 return add.reduce(sorted[indexer]*weights, axis=axis, out=out)/sumval
2857
2858 def trapz(y, x=None, dx=1.0, axis=-1):
ValueError: operands could not be broadcast together with shapes (0,) (2,)
Same result for df.boxplot()
.