How to plot bar chart in Python using matplotlib.pyplot ? Argument height must be 'xxxx' or scalar -


i have data frame named 'train' has number of variables. 1 such variable 'industry'. first 10 elements of column 'industry' follows:

train['industry'][:10] 0    office supplies     1    unknown             2    misc services       3    social services     4    unknown             5    manufacturing       6    social services     7    office supplies     8    entertainment       9    construction        name: industry, dtype: object 

i trying plot bar chart using matplotlib.pyplot plt library industry type on x-axis , frequency on y-axis. not sure should value of 'height' argument?

plt.bar(train['industry'], height = ) 

height frequency. here's example

  1. make array of length len(train.index)

  2. make bar chart without industry names - plt.bar(array, frequency) . frequency/height cannot string. needs numerical. if isn't, convert using pd.to_numeric

  3. put industry names array

  4. use set_xticklabels(industries) change labels


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -