ค้นหาชื่อนักเรียนที่มีทั้งสัตว์เลี้ยงแมวและสุนัข
Find the first name of students who have both cat and dog pets .
df_student = pd.DataFrame(columns=['fname', 'stuid']); df_has_pet = pd.DataFrame(columns=['stuid', 'petid']); df_pets = pd.DataFrame(columns=['petid', 'pettype'])
df_cats = df_has_pet.merge(df_pets[df_pets['pettype'] == 'cat'], on='petid').merge(df_student, on='stuid')['fname']; df_dogs = df_has_pet.merge(df_pets[df_pets['pettype'] == 'dog'], on='petid').merge(df_student, on='stuid')['fname']; pd.Series(list(set(df_cats) & set(df_dogs)))