我无法在最近两个小时内解决这个问题。尝试绘制已过滤的数据帧时,我一直收到KeyError
。这是我希望绘制的数据框的代码(我希望有x-axis= 'LengthService'
和y-axis= 'AbsentHours'
):
df2_ls = df2['LengthService'] >= 4.0
df2['AbsentHours'] >= 100
df2[df2_ls].head()
df2_ls = pd.DataFrame(df2_ls)
@RafaelC这里是df2's columns
:
索引([['EmployeeNumber','Gender','LengthService','AbsentHours'],dtype ='object')
我觉得我需要re-index
列还是将某些列定义为keys
?
这是KeyError
消息行:
-> 3078 return self._engine.get_loc(key)
KeyError: 'AbsentHours'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-89-2c9592ccb984> in <module>()
1 # Male bar plot
2
----> 3 Male = df3_ls.plot.bar(x='LengthService', y='AbsentHours', rot=0)
4