Left join

การรวมข้อมูลด้วย pandas

Aaren Stubberfield

Instructor

ทบทวนสั้น ๆ

แผนภาพ Venn ของ Inner join

การรวมข้อมูลด้วย pandas

Left join

แผนภาพ Venn ของ Left join

การรวมข้อมูลด้วย pandas

Left join

ภาพตารางสองตารางที่รวมกันด้วย Left join

การรวมข้อมูลด้วย pandas

ชุดข้อมูลใหม่

โลโก้ของ The Movie DB

คอลลาจโปสเตอร์ภาพยนตร์

การรวมข้อมูลด้วย pandas

ตาราง movies

movies = pd.read_csv('tmdb_movies.csv')
print(movies.head())
print(movies.shape)
  id     original_title   popularity       release_date
0 257    Oliver Twist     20.415572        2005-09-23  
1 14290  Better Luck ...  3.877036         2002-01-12  
2 38365  Grown Ups        38.864027        2010-06-24  
3 9672   Infamous         3.6808959999...  2006-11-16  
4 12819  Alpha and Omega  12.300789        2010-09-17  
(4803, 4)
การรวมข้อมูลด้วย pandas

ตาราง taglines

taglines = pd.read_csv('tmdb_taglines.csv')
print(taglines.head())
print(taglines.shape)
  id      tagline
0 19995   Enter the World of Pandora.
1 285     At the end of the world, the adventure begins.
2 206647  A Plan No One Escapes
3 49026   The Legend Ends
4 49529   Lost in our world, found in another.
(3955, 2)
การรวมข้อมูลด้วย pandas

การ merge ด้วย Left join

movies_taglines = movies.merge(taglines, on='id', how='left')
print(movies_taglines.head())
  id     original_title   popularity       release_date  tagline        
0 257    Oliver Twist     20.415572        2005-09-23    NaN            
1 14290  Better Luck ...  3.877036         2002-01-12    Never undere...
2 38365  Grown Ups        38.864027        2010-06-24    Boys will be...
3 9672   Infamous         3.6808959999...  2006-11-16    There's more...
4 12819  Alpha and Omega  12.300789        2010-09-17    A Pawsome 3D...
การรวมข้อมูลด้วย pandas

จำนวนแถวที่ได้รับ

print(movies_taglines.shape)
(4805, 5)
การรวมข้อมูลด้วย pandas

มาฝึกกันเถอะ!

การรวมข้อมูลด้วย pandas

Preparing Video For Download...