以下代码返回错误
KeyError: 'duration'
for i in range(0, 3):
exam_df['duration'] = pd.to_datetime(i,(exam_df['Duration '])[i])
exam_df['grade'] = exam_df['Grade'].astype(np.int64)
exam_df.plot.scatter(x='duration', y='grade')
答案 0 :(得分:3)
我认为你拼错关键'持续时间',试着改变:
exam_df['duration'] = pd.to_datetime(i,(exam_df['Duration '])[i])
使用:
exam_df['duration'] = pd.to_datetime(i,(exam_df['duration'])[i])