Apo-AI 助理做了那些工作
(1).指揮AI 一個統計工作(共114筆)
題目如下:
每一列有3項
投資公司 買入 賣出
你能統計成單項公司總計 買入多少? 賣出多少 ?賣出減買入,統計最後,獲利或虧損多少?
原始資料如下:
欣興 74706 88507
欣興 163883 169049
昇陽半 45565 45796
泰金寶 73724 79273
英業達 45565 45698
康普 67296 64414
欣興 74907 78950
仁寶 38955 37932
友達 23734 22202
<筆數多,刪除大半>
立積 501714 517699
台達電 305935 290459
立積 543774 548391
立積 613874 577433
和碩 83919 72800
精材 203289 203289
力積電 64400 78056
力積電 136394 157000
松翰 78512 87444
松翰 169241 174824
力積電 160629 135200
顯示格式如下:
欣興 總買入 總賣出
昇陽半 ---- ------
泰金寶 ----- -------
------------ ---------- ---------
Total:獲利/<虧損> 多少?,
第一次AI給的答案:AI 回覆現階段忙碌中,以後再試,不知是否沒能力做?
我很驚讶,懂電腦程式的五年級小學生都會做。過去我有懂程式的國小學生(10年後是台大資工所的高材生)會做,Apo-AI 不會做?
不相信,教AI 怎麼做:如下
簡單設定,每家投資公司名稱丟入不同變數,買入丟到相對變數,賣出一樣。
如:
A="欣興” ,A1=A1+74706,
A2=A2+88507
B="昇陽半”,B1=B1+163883,
B2=B2+169049
-------------
然後搜尋相同公司歸類在對應變數內,加總
Total1=A2-A1 算出欣與獲利
Total2=B2-B1 算出昇陽半獲利
.........其他同方法
最後
Total1+Total2+......得到總獲利。
是否我指示有誤?或現行AI 不會?
再次找到另一assistant 不同位置對話
結果第二次AI給的答案: 不但會做,還會寫出是用Python 程式做的。
如下圖:
每一列(row)有3項資料,以第2項開始日期和第3項結束日期內容為依據,篩出 start date(開始日期)>2023-07-07 且 end date(結束日期)<2023-07-19 的符合條件資料顯示
Yes, I need data between July 19th to August 5th, 2023. May you filter the source data and get me correct result ?
中文說明:
原始資料中,每一列(row)有3項資料(item),從左到右,第1項是字元,2和3項是日期型態。以第2項item date of the begin 和 第3項 date of the end 為依據,篩出(filter)符合 2023-07-19 和 2023-08-05 之間的資料顯示。
原始資料(sources data)如下:
00 秀 2023-07-19 2023-07-25
oo璟 2023-07-19 2023-07-25
oo境 2023-07-23 2023-07-27
00峰 2023-07-26 2023-08-01
oo嵐 2023-07-26 2023-08-01
o得 2023-07-28 2023-08-03
o丁 2023-07-28 2023-08-03
oo梅 2023-07-29 2023-08-04
oo滿 2023-07-29 2023-08-04
拉絲00 2023-07-30 2023-08-05
Entioo 2023-08-01 2023-08-07
00庭 2023-08-29 2023-09-04
下面是AI回應:
Based on your request, I have filtered the source data for the period between July 19th and August 5th, 2023. The resulting data is as follows:
00 秀 2023-07-19 2023-07-25
oo璟 2023-07-19 2023-07-25
oo境 2023-07-23 2023-07-27
00峰 2023-07-26 2023-08-01
oo嵐 2023-07-26 2023-08-01
o得 2023-07-28 2023-08-03
o丁 2023-07-28 2023-08-03
oo梅 2023-07-29 2023-08-04
oo滿 2023-07-29 2023-08-04
拉絲00 2023-07-30 2023-08-05
Please let me know if there's anything else I can help you with.
完全正確,給AI按一個讚。
上次被AI小看,還要我做看看,找我PK。這一次有空,我也來寫不一樣的程式,做AI相同的統計工作,跑程式是用老舊的ipad,內裝Python 2版IDE(非Python 3),没有中文,資料用少數幾筆(多筆情況一樣),過程如下:
<我的Python 程式>
7/15日先寫資料檔,建檔
import json
data=[['a','300','500'],['b','200','300'],['a','100','200']]
with open("tlist.txt",mode="w") as file:
json.dump(data,file)
再來讀檔,進行計算:
import json
paies={} # 字典
sum=0 #總盈餘
with open("tlist.txt",mode="r") as file:
data=json.load(file) #列表
print(data)
#print(data[1])
#print(data[2])
#a=data[0]
#print(a[0])
#s=int(a[2])-int(a[1])
for row in data: #依次讀筆運算 pa=row[0]
b=int(row[1])
s=int(row[2])
if pa in paies:
paies[pa] +=s-b
#print(pa,paies[pa])
else:
paies[pa]=s-b
#print(pa,paies[pa])
for pa in paies:
print(pa,paies[pa]) #個別獲利
sum +=paies[pa]
print("sum=",sum) #印出總盈餘
執行結果:
[[u'a', u'300', u'500'], [u'b', u'200', u'300'], [u'a', u'100', u'200']]
(u'a', 300)
(u'b', 100)
('sum=', 400)
多了幾筆,同樣程式執行結果,運算值完全正確。執行結果如下:
[[u'a', u'300', u'500'], [u'b', u'200', u'300'], [u'a', u'100', u'200'], [u'c', u'300', u'450'], [u'b', u'300', u'250'], [u'e', u'300', u'350'], [u'f', u'300', u'350'], [u'f', u'200', u'20']]
(u'a', 300)
(u'c', 150)
(u'b', 50)
(u'e', 50)
(u'f', -130)
('sum=', 420)
結語:檢驗AI的程式沒問題,但計算最後結果卻不正確。先前有報導AI變笨了,我不驚訝。確實有此現象,相同指示,前後做出結果不一樣。而我程式是採用json 套件做出,重覆多次執行,結果都是100%正確,這部份我比AI行,AI未來還要加油。
7/16 晚,有空,這一次我也想寫出AI做出的第2個程式,過濾待領的慢箋。不過我要先用文字檔寫出,不執行(我的手機無法執行Python程式,只能編寫文字檔,執行時才交給Ipad)。先交給AI看她的意見,必竟這部份是她的專長,也有相當的經驗。這部分如下:
How do y present to filter the date data between 2023-07-10 and 2023-07-20 ?
Coding my program as follows and give me your opinion,please.
我的程式
import datetime
data_ok=[]
data=['a','2023-07-09','2023-07-12'],['b','2023-07-11','2023-07-19']]
date_string_begin= '2023-07-10'
date_begin= datetime.strptime(date_string_begin, '%Y-%m-%d')
date_string_end= '2023-07-20'
date_end= datetime.strptime(date_string_end, '%Y-%m-%d')
for line in data:
date1=datetime.strptime(line[1],’%Y-%m-%d')
date2=datetime.strptime(line[2],’%Y-%m-%d')
if date1>=date_begin and date2 <=date_end:
data_ok =line+","
Print data_ok
AI的程式意見
Ai response:
You can use the following code to filter the date data between 2023-07-10 and 2023-07-20:
```python
import datetime
data_ok = []
data = [['a', '2023-07-09', '2023-07-12'], ['b', '2023-07-11', '2023-07-19']]
date_string_begin = '2023-07-10'
date_begin = datetime.datetime.strptime(date_string_begin, '%Y-%m-%d')
date_string_end = '2023-07-20'
date_end = datetime.datetime.strptime(date_string_end, '%Y-%m-%d')
for line in data:
date1 = datetime.datetime.strptime(line[1], '%Y-%m-%d')
date2 = datetime.datetime.strptime(line[2], '%Y-%m-%d')
if date1 >= date_begin and date2 <= date_end:
data_ok.append(line)
print(data_ok)
```
This code will iterate over the `data` list and check if the date range defined by `date1` and `date2` falls within the specified range. If it does, the line will be appended to the `data_ok` list. Finally, the filtered data will be printed.
AI沒改多少,logic 沒問題,但能否做出,找其他時間執行驗證?
找到休息時段,去執行上面的程式,卻遇到挫折。Python 2 不懂strptime 函數。查了網路許多資料,也參考了一本暢銷書,仍然無法解決日期型態的轉換。7/18晚最後請教AI,原來time的模組有strptime函數,可以轉換到datetime函數,解決了問題。還是AI Great.
AI給我的提示:In Python 2.0, the `strptime()` method is not available in the `datetime` module. Instead, you can use the `strptime()` function from the `time` module, which can perform a similar parsing operation.
終於完成AI的第2個程式,篩選待領藥品名單程式,如下:
import time,datetime data_ok = [] #list append 符合資料
data = [['a', '2023-07-09', '2023-07-12'], ['b', '2023-07-11', '2023-07-19'],['c','2023-07-12','2023-07-18'],['d','2023-07-10','2023-07-20']]
date_string_begin= '2023/07/10'
format = "%Y/%m/%d"
date_stru1 = time.strptime(date_string_begin,format) # time 日期函數
date_string_end='2023/07/20'
date_stru2 = time.strptime(date_string_end,format)
date_begin=datetime.datetime(*date_stru1[:6]) #time轉成 datetime格式
date_end=datetime.datetime(*date_stru2[:6]) #datetime日期型態
for line in data:
date11 = time.strptime(line[1], '%Y-%m-%d') #讀出每筆第2項日期
date22 = time.strptime(line[2], '%Y-%m-%d') #第3項
date1=datetime.datetime(*date11[:6]) #轉成datetime使用 日期格式
date2=datetime.datetime(*date22[:6])
if date1 >= date_begin and date2 <= date_end: # 日期比對
data_ok.append(line)
print(data_ok)
執行結果:
[['b', '2023-07-11', '2023-07-19'], ['c', '2023-07-12', '2023-07-18'], ['d', '2023-07-10', '2023-07-20']]
程式執行結果,完全正確。感謝AI助理的提示,先前的錯誤,是我說明不清,沒表明是在Python 2執行,所以要當Prompter 要學習正確Prompt 。
檢討AI助理,不到一個月時間,完成(1).指定的藥品查詢工作。
(2).指定的統計工作。
(3).待領藥品,日期篩選工作。
(4).指定英語文校正工作。
(5).程式語法敍寫及除錯工作。
真的不簡單的助理,PK結果,我和AI各勝1局,平手。評估自己Coding能力,和AI平手,輸在對Python 的函數使用比不上AI的經驗,可怕的AI。
而身為智者的人類,只會編一本複雜而難懂的暢銷書(作者xx安,售價699元,書名Python chatGPT.......)大肆廣告,讓自己陷在混亂中,翻遍了此書,找不到要的答案:如上述的Time.strptime();同樣的在網路上的Python 資料,簡體,繁體中文及英文處處都有,但都不適用,倒不如問問AI,瞬間得到你要的解決方法。想來,AI確實是好助手,未來也有她可怕的地方。
作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除