【程式媛曬83行程式碼】雲棲社群聚能聊專家,背後83行程式碼的故事
在中國程式媛中,他們的程式碼有什麼樣的魅力,Aone聯合雲棲社群、餓了麼、釘釘、阿里雲、天貓、口碑發起首屆程式媛比碼活動——不秀大長腿,秀高智商;不秀美圖照,秀程式碼圖,參與曬碼互動遊戲贏“83行程式碼”T恤!
我們來說說這群女工程師的第83行程式碼及程式碼背後的故事:
平時習慣於用Jupyter Notebook寫程式碼,以至於很多程式碼像是這樣:
# 分塊計算缺失程度(23塊)
block_list = [1,5,6,20,24,28,32,36,48,52,54,64,72,76,102,107,111,155,161,166,211,254,278,298]
for i in tqdm(range(len(block_list)-1)):
tmp_df = train_test.iloc[:,block_list[i]-1:block_list[i+1]-1]
print(tmp_df.columns)
tmp_df_T = tmp_df.T
tmp_df[`count`] = tmp_df_T.count()
train_test[`count_f` + str(block_list[i]) + `_f` +str(block_list[i+1])] = tmp_df[`count`]
train_test[`count_label_f` + str(block_list[i]) + `_f` +str(block_list[i+1]-1)]=np.where(train_test[`count_f` + str(block_list[i]) + `_f` +str(block_list[i+1])] > 0,0,1)
# 計算佔比(基於date)
for i in tqdm(r_list):
df_dratio = pd.DataFrame()
for j in date_list:
df_tmp = train_test[train_test[`date`] == j]
f_ratio = pd.DataFrame(df_tmp[i].value_counts())
f_ratio[`date`] = j
f_ratio[i + `_rcount`] = f_ratio[i]
f_ratio[i + `_ratio`] = f_ratio[i]/len(df_tmp)
f_ratio[i] = f_ratio.index
f_ratio = f_ratio.reset_index(drop = True)
df_dratio = pd.concat([df_dratio, f_ratio], axis = 0)
df_dratio = df_dratio.reset_index(drop = True)
train_test = train_test.merge(df_dratio,on = [`date`,i],how = `left`)
比較喜歡的一段程式碼是這樣:
import copy
def cal_all_altcol_1(col_, labelcol = None, error_corr = False):
# if labelcol is not None:
# print("pcsing by groups")
col = copy.deepcopy(col_)
colname = col.columns[0]
if(error_corr == True):
if labelcol is not None:
mean = pd.DataFrame(calmean(col, labelcol))
alt_col = [col, 1 / col, col-mean, np.fabs(col-mean)]
alt_col_name = [colname + "_X", colname + "_1/X", colname + "_Xerr", colname + "_Xerr_abs"]
else:
mean = calmean(col, labelcol)
alt_col = [col, 1 / col, np.fabs(col-mean)]
alt_col_name = [colname + "_X", colname + "_1/X", colname + "_Xerr_abs"]
elif(error_corr == False):
alt_col = [col , 1 / col]
alt_col_name = [colname + "_X", colname + "_1/X"]
alt_list = pd.concat(alt_col, axis = 1)
alt_list.columns = alt_col_name
return alt_list
def cal_all_altcol_1_base(col_, labelcol = None, error_corr = False):
# 只取正負列
# if labelcol is not None:
# print("pcsing by groups")
col = copy.deepcopy(col_)
colname = col.columns[0]
if(error_corr == True):
if labelcol is not None:
mean = pd.DataFrame(calmean(col, labelcol))
alt_col = [col, np.fabs(col-mean), col-mean, ]
alt_col_name = [colname + "_X", colname + "_Xerr_abs", colname + "_Xerr"]
else:
mean = pd.DataFrame(calmean(col, labelcol))
print(mean)
alt_col = [col, np.fabs(col-mean)]
alt_col_name = [colname + "_X", colname + "_Xerr_abs"]
elif(error_corr == False):
alt_col = [col]
alt_col_name = [colname + "_X"]
alt_list = pd.concat(alt_col, axis = 1)
# print (alt_list)
alt_list.columns = alt_col_name
return alt_list
def cal_all_altcol_2(col_i, col_j, labelcol = None, error_corr = False):
# if labelcol is not None:
# print("pcsing by groups")
coli = copy.deepcopy(col_i)
colj = copy.deepcopy(col_j)
coliname = coli.columns[0]
coljname = colj.columns[0]
colbet = coliname + "_" + coljname
coli.columns, colj.columns = [colbet], [colbet] # 需要把列名統一不然不能直接減
Plus = coli + colj
Minus = coli - colj
Multiply = coli * colj
Divide_1 = coli / colj
Divide_2 = colj / coli
everynum_perpart = 5
if(error_corr == True):
P_mean = pd.DataFrame(calmean(Plus, labelcol))
Mi_mean = pd.DataFrame(calmean(Minus, labelcol))
Mu_mean = pd.DataFrame(calmean(Multiply, labelcol))
D1_mean = pd.DataFrame(calmean(Divide_1, labelcol))
D2_mean = pd.DataFrame(calmean(Divide_2, labelcol))
if labelcol is not None:
alt_col = [Plus, Minus, Multiply, Divide_1, Divide_2,
np.fabs(Plus - P_mean), np.fabs(Minus - Mi_mean), np.fabs(Multiply - Mu_mean),
np.fabs(Divide_1 - D1_mean), np.fabs(Divide_2 - D2_mean),
Plus - P_mean, Minus - Mi_mean, Multiply - Mu_mean,Divide_1 - D1_mean, Divide_2 - D2_mean]
alt_col_name = [colbet + "_X+Y", colbet + "_X-Y", colbet + "_X*Y", colbet + "_X/Y", colbet + "_Y/X",
colbet + "_X+Yerr_abs", colbet + "_X-Yerr_abs", colbet + "_X*Yerr_abs",
colbet + "_X/Yerr_abs", colbet + "_Y/Xerr_abs",
colbet + "_X+Yerr", colbet + "_X-Yerr", colbet + "_X*Yerr",
colbet + "_X/Yerr", colbet + "_Y/Xerr",]
elif labelcol is None:
alt_col = [Plus, Minus, Multiply, Divide_1, Divide_2,
np.fabs(Plus - P_mean), np.fabs(Minus - Mi_mean), np.fabs(Multiply - Mu_mean),
np.fabs(Divide_1 - D1_mean), np.fabs(Divide_2 - D2_mean)]
alt_col_name = [colbet + "_X+Y", colbet + "_X-Y", colbet + "_X*Y", colbet + "_X/Y", colbet + "_Y/X",
colbet + "_X+Yerr_abs", colbet + "_X-Yerr_abs", colbet + "_X*Yerr_abs",
colbet + "_X/Yerr_abs", colbet + "_Y/Xerr_abs"]
elif(error_corr == False):
alt_col = [Plus, Minus, Multiply, Divide_1, Divide_2]
alt_col_name = [colbet + "_X+Y", colbet + "_X-Y", colbet + "_X*Y", colbet + "_X/Y", colbet + "_Y/X"]
alt_list = pd.concat(alt_col, axis = 1)
alt_list.columns = alt_col_name
# print(alt_list)
return alt_list
# def cal_all_alt2tol(coli, colj, )
# cal_all_altcol_2(test, test2)
與海洋的雲小姐姐互動,為她打call——>點選進去曬碼
更多小姐姐,點選進入檢視程式碼
有被程式碼耽誤的釘釘吃貨程式媛,寫程式碼寫到忘記吃飯的——採霜
她急需能把她從程式碼中叫醒去吃飯的小夥伴,趕緊勾搭;
http://yq.aliyun.com/roundtable/126499/answer/170319#visit170319
有以程式碼為樂的餓了麼大前端打(bei)雜(guo)工程師——敖天羽
http://yq.aliyun.com/roundtable/126499/answer/170299#visit170299
還有全棧美女工程師——前端後端一鍋端的——墨瑜女神
http://yq.aliyun.com/roundtable/126499/answer/170316#visit170316
還有阿里雲活好碼贊,像男人一樣活著的技術專家小姐姐——清宵http://yq.aliyun.com/roundtable/126499/answer/170296#visit170296
和天貓Java程式媛,happy(被)來(逼)的——採月
http://yq.aliyun.com/roundtable/126499/answer/170354#visit170354
阿里口碑 搜尋推薦組的JAVA女工程師——妍霏
http://yq.aliyun.com/roundtable/126499/answer/214059#visit214059
阿里口碑基礎平臺技術部的工程師-銜遠,一個技術與馬甲線並存的mm
http://yq.aliyun.com/roundtable/126499/answer/248798#visit248798
雲棲社群聚能聊專家,具有知性溫婉氣質的——海洋的雲http://yq.aliyun.com/roundtable/126499/answer/170290#visit170290
福州市五佰網路科技有限公司的Java女工程師——江小白太白
http://yq.aliyun.com/roundtable/126499/answer/189332#visit189332
在下*的程式媛——cn_suqingnian
http://yq.aliyun.com/roundtable/126499/answer/170309#visit170309
交通銀行的前端女工程師——昆0830
http://yq.aliyun.com/roundtable/126499/answer/201979#visit201979
相關文章
- 袋鼠雲程式碼檢查服務,揭秘高質量程式碼背後的秘密
- 無聊的html程式碼HTML
- dyld背後的故事&原始碼分析原始碼
- 聊一聊 php 程式碼提示PHP
- 《程式碼之美》的故事
- 使用碼雲管理你的專案程式碼
- 今天的無聊html程式碼HTML
- 傳說中程式猿與程式媛的後代?
- IT去中心化背後的低程式碼平臺中心化
- 為你揭祕小程式音視訊背後的故事......
- 程式猿與程式媛
- 程式碼故事:漢德的救贖
- 艱難前行的故事 (《夢斷程式碼》讀後感)薦
- 無聊程式碼一段
- 無聊程式碼 jQuery Mobile 骨架jQuery
- GUI介面程式碼(家)GUI
- 探索低程式碼高擴充性背後的奧祕
- 你的程式碼或許漂亮,但我的程式碼能執行
- 開發者故事|程式碼虐我千萬遍,我待程式碼如“初戀”
- Python 萬能程式碼模版:爬蟲程式碼篇Python爬蟲
- 無聊程式碼,測試bootstrap.boot
- 《碼出高效:Java開發手冊》背後的故事Java
- 你見過背誦程式碼的程式設計師嗎?程式設計師
- 知乎專案程式碼閱後總結
- 女碼農的真實生活:程式“媛”無法賣萌
- 郭超:阿里雲Cassandra背後的故事阿里
- python自學,小知識程式碼,能飛天的小程式碼Python
- C程式執行的背後C程式
- 開源夜聊欄目開播:聊聊新晉 CNCF 專案 sealer 背後的故事
- 程式媛的黃金時代
- 網校程式原始碼:網校頻頻倒閉的背後原因原始碼
- 併發程式背後的故事以及併發當中的記憶體模型記憶體模型
- 程式碼審查的藝術:Dropbox 的故事
- 每一座屎山程式碼背後,都藏著一堆熟讀程式碼規範的研發
- 聊一聊Java8 Optional,讓你的程式碼更加優雅Java
- 技術趣聞:十三種程式語言和它們名稱背後的故事
- 當程式設計師老去 揭祕不為人知背後的辛酸故事程式設計師
- [譯] 斷點:像專家一樣除錯程式碼斷點除錯