\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) try: return self.enter code here_engine.get_loc(casted_key) 除了 KeyError 作为错误代码在这里:
~\anaconda3\lib\site-packages\pandas_libs\index.pyx 在 pandas._libs.index.IndexEngine.get_loc()
~\anaconda3\lib\site-packages\pandas_libs\index.pyx 在 pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi 在 pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas_libs\hashtable_class_helper.pxi 在 pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError:'YearsInCurrentRole'
上述异常是以下异常的直接原因:
KeyError Traceback (最近一次调用最后一次) ~\AppData\Local\Temp/ipykernel_25644/809870847.py in 23 # Generate and plot 24 x = df['Age'].values ---> 25 y = df['YearsInCurrentRole' ].values 26 sns.kdeplot(x, y, cmap=cmap, shade=True, ax=axes[0,2]) 27 axes[0,2].set(title = '年龄对年龄的作用')
~\anaconda3\lib\site-packages\pandas\core\frame.py in getitem(self, key) 3456 if self.columns.nlevels > 1: 3457 return self._getitem_multilevel(key) -> 3458 indexer = self.columns .get_loc(key) 3459 if is_integer(indexer): 3460 indexer = [indexer]
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3361 return self._engine.get_loc(casted_key) 3362 除了 KeyError as err:enter code here - > 3363 如果 is_scalar(key) 和 isna(key) 而不是 self.hasnans,则从 err 3364 3365 引发 KeyError(key)
KeyError:'YearsInCurrentRole'