You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This snippet correctly plots in the first three cases, but errors in the last case, saying (in the relevant part):
/venv/local/lib/python2.7/site-packages/matplotlib/axes/_axes.pycinhist(self, x, bins, range, normed, weights, cumulative, bottom, histtype,
align, orientation, rwidth, log, color, label, stacked, **kwargs)
5602# Massage 'x' for processing.5603# NOTE: Be sure any changes here is also done below to 'weights'->5604ifisinstance(x, np.ndarray) ornotiterable(x[0]):
5605# TODO: support masked arrays;5606x=np.asarray(x)
(which then descends into a KeyError in the bowels of pandas).
So seems like the issue here is that x[0] is being used to find the first element of the input data (which would work fine if the input data is a numpy.ndarray). But in this case x is a pandas.Series and as a result x[0] is an index lookup rather than a normal slice. This works fine on axes[1] since in that case the histogrammed series includes 0 in its index. However, on axes[3], the histogrammed data no longer includes 0 in the index and things fall apart.
The text was updated successfully, but these errors were encountered:
As suggested by @tacaswell in that thread, perhaps the more robust way to get the first element of the passed data is to request next(iter(x)) rather than simply requesting x[0].
This snippet correctly plots in the first three cases, but errors in the last case, saying (in the relevant part):
(which then descends into a KeyError in the bowels of pandas).
So seems like the issue here is that
x[0]
is being used to find the first element of the input data (which would work fine if the input data is anumpy.ndarray
). But in this casex
is apandas.Series
and as a resultx[0]
is an index lookup rather than a normal slice. This works fine onaxes[1]
since in that case the histogrammed series includes0
in its index. However, onaxes[3]
, the histogrammed data no longer includes0
in the index and things fall apart.The text was updated successfully, but these errors were encountered: