Pandas Histogram Ignoring Invalid Data; Limit X-range
I have a dataframe which consists of a mix of text and numerical data, with some values of -999 representing missing or invalid data. As a toy example, let's say it looks like this
Solution 1:
Instead of bins=1000
, you can specify
df2.hist('C', bins=range(0,10))
Or if you want to align the histogram boxes in the middle:
df2.hist('C', bins=np.arange(0.5,11,1))
Output:
Solution 2:
df2[df2['C'] > -999].hist('C')
will suffice for all of your purposes. Specifying 1000 bins is not necessary.
Post a Comment for "Pandas Histogram Ignoring Invalid Data; Limit X-range"