title: "KeyError 0.0" when using another dataframe containing standard deviation as error bars for the y axis
body: <p>I have some code that I am unable to figure out the solution to (despite much googling and searching).
  Basically, I have a scipt that compiles two files derived from the same data - one file is a table of the average at each wavelength for six groups, and the other is the exact same but containing the standard deviation (both tables are the same size, same headers, etc). Plotting the files (df2) for the average produces graphs, no problem.</p>
  
  <p>However when I try to use the dataframe containing the standard deviation (df3) values, as the error bars for the graph, I get "KeyError 0.0".
  Is anyone able to help me figure out what's going wrong? Much appreciated and many thanks.</p>
  
  <p>My script is below.</p>
  
  <pre><code>wave = pd.read_csv("Wavelength_to_Index_Conversion.csv") #contains a list of wavelengths used to use later on
  ##
  #GET AVERAGE VALUES OF DATA FROM EACH FILE
  ##
  for filename in os.listdir(indir):
      print (i)
      df1 = pd.read_csv(indir + filename) #imports file
      print(filename)
      filename = filename[:-12] #removes extra filename and extension
      print(filename)
      if i == 0:
          df2 = pd.DataFrame(data=None, columns=None,index=df1.index)
      e = df1['Average']
      df2 = df2.assign(temp=e.values)
      print (filename)
      df2.rename(columns={'temp': str(filename)}, inplace=True)
  
      i = i+1
  
  df2.set_index(wave['Wavelength'], inplace=True)
  df2.to_csv("Total_Average.csv")
  df2t = df2.T
  df2t.to_csv("Total_Average_T.csv")
  
  ##
  ## GET STD DEV
  ##
  i = 0
  for filename in os.listdir(indir):
      print (i)
      df1 = pd.read_csv(indir + filename) #imports file
      print(filename)
      filename = filename[:-12]
      print(filename)
      if i == 0:
          df3 = pd.DataFrame(data=None, columns=None,index=df1.index)
      e = df1['Std Dev']
      df3 = df3.assign(temp=e.values)
      print (filename)
      df3.rename(columns={'temp': str(filename)}, inplace=True)
  
      i = i+1
  df3.set_index(wave['Wavelength'], inplace=True)
  df3.to_csv("Total_Std Dev.csv")
  
  #plt.rc('font', family='serif', size=13)
  #plt.rc('font', family='san-serif', size=13)
  
  
  #plt.ylim(0, 60)    
  #plt.xlim(400, 900)
  plt.title('Title',fontsize=20)
  plt.xlabel('Wavelength (nm)',fontsize=15)
  plt.ylabel('Reflectance (%)',fontsize=15)
      #plt.autoscale(enable=True, axis=u'both', tight=False)
  plt.grid(False)
  df2.plot(x = wave['Wavelength'], xlim=(400,850), ylim=(0,60), yerr=df3) #ERROR HERE WHENEVER yerr=df3 IS USED
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Here's the error I'm given.</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "&lt;ipython-input-8-d121c6b80d76&gt;", line 1, in &lt;module&gt;
      runfile('C:/Users/user/Documents/PhD/Data Manipulation and Graphs/Spectrometry/Plotting All Files into a Graph [X]/Plotting Spectral.py', wdir='C:/Users/user/Documents/PhD/Data Manipulation and Graphs/Spectrometry/Plotting All Files into a Graph [X]')
  
    File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
      execfile(filename, namespace)
  
    File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)
  
    File "C:/Users/jdstam/Documents/PhD/Data Manipulation and Graphs/Spectrometry/Plotting All Files into a Graph [X]/Plotting Spectral.py", line 115, in &lt;module&gt;
      df2.plot(x = wave['Wavelength'], xlim=(400,850), ylim=(0,60), yerr=df3)
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 3671, in __call__
      sort_columns=sort_columns, **kwds)
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 2556, in plot_frame
      **kwds)
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 2384, in _plot
      plot_obj.generate()
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 987, in generate
      self._make_plot()
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 1664, in _make_plot
      **kwds)
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 1678, in _plot
      lines = MPLPlot._plot(ax, x, y_values, style=style, **kwds)
  
    File "C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 1293, in _plot
      return ax.errorbar(x, y, **kwds)
  
    File "C:\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 1811, in inner
      return func(ax, *args, **kwargs)
  
    File "C:\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py", line 2963, in errorbar
      iterable(yerr[0]) and len(yerr[0]) &gt; 1))):
  
    File "C:\Anaconda3\lib\site-packages\pandas\core\series.py", line 557, in __getitem__
      result = self.index.get_value(self, key)
  
    File "C:\Anaconda3\lib\site-packages\pandas\core\index.py", line 3884, in get_value
      loc = self.get_loc(k)
  
    File "C:\Anaconda3\lib\site-packages\pandas\core\index.py", line 3942, in get_loc
      tolerance=tolerance)
  
    File "C:\Anaconda3\lib\site-packages\pandas\core\index.py", line 1759, in get_loc
      return self._engine.get_loc(key)
  
    File "pandas\index.pyx", line 137, in pandas.index.IndexEngine.get_loc (pandas\index.c:3979)
  
    File "pandas\index.pyx", line 157, in pandas.index.IndexEngine.get_loc (pandas\index.c:3843)
  
    File "pandas\hashtable.pyx", line 498, in pandas.hashtable.Float64HashTable.get_item (pandas\hashtable.c:9556)
  
    File "pandas\hashtable.pyx", line 504, in pandas.hashtable.Float64HashTable.get_item (pandas\hashtable.c:9494)
  
  KeyError: 0.0
  </code></pre>
  
  <p>EDI2:</p>
  
  <p>i. Output for df2.head()</p>
  
  <pre><code>            Mon18th_C24_20%  Mon18th_C24_50%  Mon18th_C24_80%  Mon18th_Col0_20%  Mon18th_Col0_50%  Mon18th_Col0_80%
  Wavelength                                                                                                         
  341.514           -1.963704        32.036429        13.413667         -1.396250            39.647        -23.480313
  341.892           -1.963704        32.036429        13.413667         -1.396250            39.647        -23.480313
  342.269           11.653704       -44.896786       180.915667         -6.503438            38.840         50.237812
  342.646           18.801111       305.569286       532.147000        -27.857500           504.351         66.496562
  343.024           28.421852        48.280000        65.551000        968.713437            79.782         63.419688
  </code></pre>
  
  <p>ii. Output for df3.head()</p>
  
  <pre><code>            Mon18th_C24_20%  Mon18th_C24_50%  Mon18th_C24_80%  Mon18th_Col0_20%  Mon18th_Col0_50%  Mon18th_Col0_80%
  Wavelength                                                                                                         
  341.514          103.027866       121.768024        98.039234         60.476486        101.865202        325.329848
  341.892          103.027866       121.768024        98.039234         60.476486        101.865202        325.329848
  342.269           59.441182       719.315230       643.463142         52.176211        606.273169        177.225557
  342.646           41.717983       820.680259       922.506270         73.360823        689.563817         93.132120
  343.024           47.129664        75.400200        73.011963       1728.405146         71.020783         52.873068
  </code></pre>