ระดับกลาง
4 ตุลาคม 2569หาบั๊กให้เจอ: Data Science & ML
โค้ดหนึ่งชิ้น หาบั๊กให้เจอ หรือพิสูจน์ว่าไม่มีบั๊ก
python
1import pandas as pd
2
3def enrich_orders_with_customer_emails(conn, orders: pd.DataFrame) -> pd.DataFrame:
4 cursor = conn.cursor()
5 emails = []
6 for _, row in orders.iterrows():
7 cursor.execute("SELECT email FROM customers WHERE id = %s", (row["customer_id"],))
8 result = cursor.fetchone()
9 emails.append(result[0] if result else None)
10 orders["email"] = emails
11 cursor.close()
12 return orders
13คลิกบรรทัดที่เป็นต้นเหตุของปัญหา
คำตัดสินของคุณ
วันละหนึ่งครั้ง คำตอบจะแสดงทันทีหลังจากนั้น
รักษาสถิติต่อเนื่องของคุณ
สร้างบัญชีเพื่อเก็บสถิติต่อเนื่องและติดตามความคืบหน้า