这里是代码
%%time xrange=range print ("Cleaning and parsing the tweets...\n") clean_tweet_texts = [] for i in xrange(nums[0],nums[1]): if( (i+1)%10000 == 0 ): print( "Tweets %d of %d has been processed" % ( i+1, nums[1] )) clean_tweet_texts.append(tweet_cleaner(df_tweet['text'][i]))
和错误总数消息:
Cleaning and parsing the tweets... --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <timed exec> in <module>() ~\Anaconda3\lib\site-packages\pandas\core\series.py in __getitem__(self, key) 599 key = com._apply_if_callable(key, self) 600 try: --> 601 result = self.index.get_value(self, key) 602 603 if not is_scalar(result): ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key) 2475 try: 2476 return self._engine.get_value(s, k, -> 2477 tz=getattr(series.dtype, 'tz', None)) 2478 except KeyError as e1: 2479 if len(self) > 0 and self.inferred_type in ['integer', 'boolean']: pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_value() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_value() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() KeyError: 859
无法解密,任何人都可以提供帮助
这里是代码%% time xrange = range print(“正在清理和解析推文... \ n”)clean_tweet_texts = [] for xrange(nums [0],nums [1]):if(( i + 1)%10000 == 0):print(“ Tweets%d ...
发生此错误的原因有很多,但很可能是因为数据框的索引不包含您要为其建立索引的数字(也许您删除了该行)。我可以通过以下代码获得完全相同的错误回溯。