Categories
histogram pandas python

Pandas dataframe: ValueError: num must be 1

I am getting the following error while I am trying to plot a pandas dataframe:

ValueError: num must be 1 <= num <= 0, not 1

Code:

import matplotlib.pyplot as plt
names = ['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety']
custom = pd.DataFrame(x_train) //only a portion of the csv
custom.columns = names
custom.hist()
plt.show()

I have tried to read the file again from the csv and I am getting the exact same error.

Edit:

print x_train output:

[[0.0 0.0 0.0 0.0 0.0 0.0]

[1.0 1.0 0.0 0.0 0.0 0.0]

[0.0 0.0 0.0 0.0 0.0 0.0]

…,

[0.0 0.0 0.0 0.0 0.0 0.0]

[0.3333333333333333 0.3333333333333333 2.0 2.0 2.0 2.0]

[0.0 0.0 3.0 3.0 3.0 3.0]]

Edit2:

Complete list of errors(Traceback):

Traceback (most recent call last):

File “temp.py”, line 104, in
custom.dropna().hist()

File “/home/kostas/anaconda2/lib/python2.7/site-packages/pandas/tools/plotting.py”, line 2893, in hist_frame
layout=layout)

File “/home/kostas/anaconda2/lib/python2.7/site-packages/pandas/tools/plotting.py”, line 3380, in _subplots
ax0 = fig.add_subplot(nrows, ncols, 1, **subplot_kw)

File “/home/kostas/anaconda2/lib/python2.7/site-packages/matplotlib/figure.py”, line 1005, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)

File “/home/kostas/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_subplots.py”, line 64, in init
maxn=rows*cols, num=num))