import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('Rund1.csv', header = None)
display(df)
df.plot(yerr='Intensity(%)',xerr='Position (m)')
plt.title('Run1: graph of position vs light intensity')
plt.xlabel('Position (m)')
plt.ylabel('Intensity (%)')
print(df.min())
print(df.max())
KeyError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2656 try:
-> 2657 return self._engine.get_loc(key)
2658 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index_class_helper.pxi in pandas._libs.index.Int64Engine._check_type()
KeyError: 'Position (m)'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-79-c064300052af> in <module>
5 df = pd.read_csv('Rund1.csv', header = None)
6 display(df)
----> 7 df.plot(yerr='Intensity(%)',xerr='Position (m)')
8
9
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
2940 fontsize=fontsize, colormap=colormap, table=table,
2941 yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2942 sort_columns=sort_columns, **kwds)
2943 __call__.__doc__ = plot_frame.__doc__
2944
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
1971 yerr=yerr, xerr=xerr,
1972 secondary_y=secondary_y, sort_columns=sort_columns,
-> 1973 **kwds)
1974
1975
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
1797 data.columns = label_name
1798
-> 1799 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
1800
1801 plot_obj.generate()
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, **kwargs)
948
949 def __init__(self, data, **kwargs):
--> 950 MPLPlot.__init__(self, data, **kwargs)
951 if self.stacked:
952 self.data = self.data.fillna(value=0)
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in __init__(self, data, kind, by, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, fig, title, xlim, ylim, xticks, yticks, sort_columns, fontsize, secondary_y, colormap, table, layout, **kwds)
159 yerr = kwds.pop('yerr', None)
160 self.errors = {kw: self._parse_errorbars(kw, err)
--> 161 for kw, err in zip(['xerr', 'yerr'], [xerr, yerr])}
162
163 if not isinstance(secondary_y, (bool, tuple, list,
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in <dictcomp>(.0)
159 yerr = kwds.pop('yerr', None)
160 self.errors = {kw: self._parse_errorbars(kw, err)
--> 161 for kw, err in zip(['xerr', 'yerr'], [xerr, yerr])}
162
163 if not isinstance(secondary_y, (bool, tuple, list,
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in _parse_errorbars(self, label, err)
713 # errors are a column in the dataframe
714 elif isinstance(err, string_types):
--> 715 evalues = self.data[err].values
716 self.data = self.data[self.data.columns.drop(err)]
717 err = np.atleast_2d(evalues)
~\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2925 if self.columns.nlevels > 1:
2926 return self._getitem_multilevel(key)
-> 2927 indexer = self.columns.get_loc(key)
2928 if is_integer(indexer):
2929 indexer = [indexer]
~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2657 return self._engine.get_loc(key)
2658 except KeyError:
-> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key))
2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2661 if indexer.ndim > 1 or indexer.size > 1:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index_class_helper.pxi in pandas._libs.index.Int64Engine._check_type()
KeyError: 'Position (m)'