title: Plot a histogram without the zero values in python?
body: <p>When I try to make a histogram without the zero values, I get an error: </p>
  
  <blockquote>
    <p>Traceback (most recent call last):. </p>
  </blockquote>
  
  <p>I have a list of <code>Beam_irradiance_DNI</code> values which include several zeroes. I can make histogram, but I don't want the zero values.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  import csv
  
  # Reading data from csv file
  with open('Upington_DNI.csv') as csvfile:
  readCSV = csv.reader(csvfile, delimiter=',')
  Hour_of_year = []
  Beam_irradiance = []
  for row in readCSV:
      hour = row[0]
      DNI = row[1]
      Hour_of_year.append(hour)
      Beam_irradiance.append(DNI)
  Hours_since00hrsJan1 = [float(Hour_of_year[c]) for c in       range(1,len(Hour_of_year))]
  Beam_irradiance_DNI=[float(Beam_irradiance[c]) for c in range(1,len(Beam_irradiance))]
  
  plt.figure(3)
  Beam_irradiance_DNI[ Beam_irradiance_DNI==0 ] = np.nan
  plt.hist(Beam_irradiance_DNI, color="grey")
  plt.title("Histogram for Beam irradiance - DNI")
  plt.xlabel("Beam irradiance - DNI [W/m2]"); plt.ylabel("Probability of  occurrence")
  plt.show()
  </code></pre>
  
  <p>I dont know what is wrong here.</p>