การคิวรีขั้นสูง: ใช้ประโยชน์จากความสัมพันธ์ระหว่างตาราง

Python เบื้องต้น: การนำเข้าข้อมูล

Hugo Bowne-Anderson

Data Scientist at DataCamp

ตารางเชื่อมต่อกัน

ch_3_5.003.png

Python เบื้องต้น: การนำเข้าข้อมูล

ตารางเชื่อมต่อกัน

ch_3_5.004.png

Python เบื้องต้น: การนำเข้าข้อมูล

ตารางเชื่อมต่อกัน

ch_3_5.005.png

Python เบื้องต้น: การนำเข้าข้อมูล

การ JOIN ตาราง

ch_3_5.007.png

Python เบื้องต้น: การนำเข้าข้อมูล

การ JOIN ตาราง

ch_3_5.008.png

Python เบื้องต้น: การนำเข้าข้อมูล

การ JOIN ตาราง

ch_3_5.009.png

Python เบื้องต้น: การนำเข้าข้อมูล

การ JOIN ตาราง

ch_3_5.010.png

Python เบื้องต้น: การนำเข้าข้อมูล

การ JOIN ตาราง

ch_3_5.011.png

Python เบื้องต้น: การนำเข้าข้อมูล

INNER JOIN ใน Python (pandas)

from sqlalchemy import create_engine
import pandas as pd
engine = create_engine('sqlite:///Northwind.sqlite')
df = pd.read_sql_query("SELECT OrderID, CompanyName FROM Orders 
INNER JOIN Customers on Orders.CustomerID = Customers.CustomerID", engine)
print(df.head())
   OrderID                CompanyName
0    10248  Vins et alcools Chevalier
1    10251       Victuailles en stock
2    10254          Chop-suey Chinese
3    10256     Wellington Importadora
4    10258               Ernst Handel
Python เบื้องต้น: การนำเข้าข้อมูล

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

Python เบื้องต้น: การนำเข้าข้อมูล

Preparing Video For Download...