to calculate spread beta, i got the error:
what's wrong and how to solve it?
KeyError Traceback (most recent call last)
in ()
----> 1 spread_kf = data_all[secs[1]] - data_all[secs[0]] * beta_kf['beta'] - beta_kf['alpha']
/usr/local/lib/python2.7/dist-packages/pandas/core/frame.pyc in getitem(self, key)
1995 return self.getitem_multilevel(key)
1996 else:
-> 1997 return self.getitem_column(key)
1998
1999 def _getitem_column(self, key):
/usr/local/lib/python2.7/dist-packages/pandas/core/frame.pyc in getitem_column(self, key)
2002 # get column
2003 if self.columns.is_unique:
-> 2004 return self.get_item_cache(key)
2005
2006 # duplicate columns & possible reduce dimensionality
/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in get_item_cache(self, item)
1348 res = cache.get(item)
1349 if res is None:
-> 1350 values = self.data.get(item)
1351 res = self._box_item_values(item, values)
1352 cache[item] = res
/usr/local/lib/python2.7/dist-packages/pandas/core/internals.pyc in get(self, item, fastpath)
3288
3289 if not isnull(item):
-> 3290 loc = self.items.get_loc(item)
3291 else:
3292 indexer = np.arange(len(self.items))[isnull(self.items)]
/usr/local/lib/python2.7/dist-packages/pandas/indexes/base.pyc in get_loc(self, key, method, tolerance)
1945 return self.engine.get_loc(key)
1946 except KeyError:
-> 1947 return self.engine.get_loc(self.maybecast_indexer(key))
1948
1949 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4154)()
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4018)()
pandas/hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12368)()
pandas/hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12322)()
KeyError: 'beta'