我的目标是在最终数据帧上进行数据分析,这是学生结果的组合。
我尝试过的方法:在列中添加确切的名称,然后在每一行中重复主题名称。
程序代码:https://github.com/sharath-psh/VTU-results-extractor-and-analysis-/blob/master/jpres.ipynb
=====
student_name : student1_name
student_usn : 1BI18MCA01
dataframe of student 1 :
Code Subject name Internal External Total \
0 17MCA41 ADVANCED JAVA PROGRAMMING 17 38 55
1 17MCA442 DATA WAREHOUSING AND DATA MINING 17 37 54
2 17MCA42 ADVANCED WEB PROGRAMMING 18 50 68
3 17MCA43 SOFTWARE TESTING AND PRACTICES 15 34 49
4 17MCA454 PRINCIPLES OF USER INTERFACE DESIGN 19 39 58
5 17MCA46 ADVANCED JAVA PROGRAMMING LABORATORY 18 78 96
6 17MCA47 ADVANCED WEB PROGRAMMING LABORATORY 19 78 97
7 17MCA48 SOFTWARE TESTING LABORATORY 18 80 98
8 17MCA49 SEMINAR 50 0 50
9 TOTAL : TOTAL : TOTAL : TOTAL : 625
Unnamed: 5
0 P
1 P
2 P
3 P
4 P
5 P
6 P
7 P
8 P
9 NaN
====
student_name : student2_name
student_usn : 1BI18MCA02
dataframe of student 2:
Code Subject name Internal External Total \
0 17MCA41 ADVANCED JAVA PROGRAMMING 11 37 48
1 17MCA42 ADVANCED WEB PROGRAMMING 17 46 63
2 17MCA43 SOFTWARE TESTING AND PRACTICES 14 36 50
3 17MCA454 PRINCIPLES OF USER INTERFACE DESIGN 17 39 56
4 17MCA444 CRYPTOGRAPHY AND NETWORK SECURITY 20 37 57
5 17MCA46 ADVANCED JAVA PROGRAMMING LABORATORY 15 50 65
6 17MCA47 ADVANCED WEB PROGRAMMING LABORATORY 20 62 82
7 17MCA48 SOFTWARE TESTING LABORATORY 10 73 83
8 17MCA49 SEMINAR 45 0 45
9 TOTAL : TOTAL : TOTAL : TOTAL : 549
Unnamed: 5
0 P
1 P
2 P
3 P
4 P
5 P
6 P
7 P
8 P
9 NaN
答案 0 :(得分:1)
我认为您正在寻找keys
中的pd.concat
参数:
united_df = pd.concat([df1, df2], keys=['df1','df2'])
答案 1 :(得分:-1)
编辑: @Aryerez的p.concat评论使我意识到我的最初答案是错误的。
df1 = df1.assign(student_name="student1_name").assign(student_usn="1BI18MCA01")
df2 = df2.assign(student_name="student2_name").assign(student_usn="1BI18MCA02")
df_merged = pd.concat([df1, df2])