应该是申万指数源数据变更了获取方式或地址
KeyError Traceback (most recent call last)
in ()
----> 1 swindex.get_index_cons('801060')
E:\Anaconda3\envs\py35\lib\site-packages\opendatatools\swindex\swindex_interface.py in get_index_cons(index_code)
9
10 def get_index_cons(index_code):
---> 11 return sw_agent.get_index_cons(index_code)
12
13 def get_index_daily(index_code):
E:\Anaconda3\envs\py35\lib\site-packages\opendatatools\swindex\swindex_agent.py in get_index_cons(self, index_code)
74 })
75 df = pd.DataFrame(data)
---> 76 df['start_date'] = df['start_date'].apply(lambda x : datetime.datetime.strptime(x, '%Y/%m/%d %H:%M:%S'))
77 return df, ''
78
E:\Anaconda3\envs\py35\lib\site-packages\pandas\core\frame.py in getitem(self, key)
2686 return self._getitem_multilevel(key)
2687 else:
-> 2688 return self._getitem_column(key)
2689
2690 def _getitem_column(self, key):
E:\Anaconda3\envs\py35\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key)
2693 # get column
2694 if self.columns.is_unique:
-> 2695 return self._get_item_cache(key)
2696
2697 # duplicate columns & possible reduce dimensionality
E:\Anaconda3\envs\py35\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item)
2487 res = cache.get(item)
2488 if res is None:
-> 2489 values = self._data.get(item)
2490 res = self._box_item_values(item, values)
2491 cache[item] = res
E:\Anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath)
4113
4114 if not isna(item):
-> 4115 loc = self.items.get_loc(item)
4116 else:
4117 indexer = np.arange(len(self.items))[isna(self.items)]
E:\Anaconda3\envs\py35\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3078 return self._engine.get_loc(key)
3079 except KeyError:
-> 3080 return self._engine.get_loc(self._maybe_cast_indexer(key))
3081
3082 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'start_date'