การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา
Francesca Donadoni
AI Curriculum Manager, DataCamp

def sales_trend(self):
...
if increasing > decreasing:
return "Increasing trend"
else:
return "Decreasing or stable trend"
def sales_trend(self):
"""Analyze sales data to determine the overall trend"""
[...]
คำสั่งของผู้ใช้: สร้าง docstring สำหรับฟังก์ชันนี้ โดยให้รวม:
คำตอบของโมเดล:
นี่คือ docstring ที่สมบูรณ์สำหรับฟังก์ชันของคุณ:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
[...]
"""
นี่คือ docstring ที่สมบูรณ์สำหรับฟังก์ชันของคุณ:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
Parameters
----------
self : object
An object that contains an attribute `daily_sales` (list of int or float),
which represents daily sales values in chronological order.
[...]
"""



นี่คือร่าง README.md สำหรับ class SalesAnalyzer:
SalesAnalyzer
class SalesAnalyzer ช่วยให้วิเคราะห์ข้อมูลยอดขายรายวันและตรวจสอบว่าแนวโน้มยอดขายกำลังเพิ่มขึ้นหรือลดลง/คงที่ได้อย่างง่ายดาย เหมาะสำหรับธุรกิจหรือบุคคลที่ต้องการภาพรวมยอดขายอย่างรวดเร็ว

(base) datacamp@test:~/datacamp/docstring-generation$ git diff
+
+ Raises:
+ ValueError: If daily_sales contains non-numeric values.
"""
- return sum(self.daily_sales)
+ if not all(isinstance(sale, (int, float)) for sale in self.daily_sales):
+ raise ValueError("All sales figures must be numeric.")
+ return sum(sale for sale in self.daily_sales)


การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา