stu_names = ["胡歌","林更新","金世佳","丑娟"] courses = ['语文', '数学', '英语', 'Python', '体育'] data_1 = np.array([[87., 74., 98., 84., np.nan],[79., 69., 61., 99., np.nan],[84., 84., 94., 66., np.nan],[90., 60., 72., 90., np.nan]]) df = pd.DataFrame(data=data_1,index=stu_names,columns=courses,dtype=None,copy=False) df.to_excel("学生成绩表.xlsx") df ele_names = ["胡歌","林更新","金世佳","丑娟"] ele_courses = ['统计学', '日语'] ele_data = np.array([[85., np.nan],[np.nan, 69.],[np.nan, 95.],[80., np.nan]]) df2 = pd.DataFrame(data=ele_data,index=ele_names,columns=ele_courses,dtype=None,copy=False) df2.to_excel("选修成绩表.xlsx") df2