1 import pandas as pd 2 3 4 5 6 students = pd.DataFrame([[1, 'Alice'], 7 [2, 'Bob'], 8 [13, 'John'], 9 [6,'Alex']], columns = ['student_id', 'student_name']) 10 11 12 print(students) 13 14 15 16 subjects = pd.DataFrame([['Math'], 17 ['Physics'], 18 ['Programming'], 19 ], columns = ['subject_name']) 20 21 22 print(subjects) 23 24 students['value'] = 1 25 subjects['value'] = 1 26 27 a = students.merge(subjects, how = 'outer', on = 'value') 28 del a['value'] 29 print('\n', a)
标签:笛卡尔,python,value,students,subjects,DataFrame,pd,print,Pandas From: https://www.cnblogs.com/bravesunforever/p/17649732.html