import pandas as pd
import re
import collections
excelFile = ‘2.xlsx'
df = pd.DataFrame(pd.read_excel(excelFile))
cblist=[]
df1=df['Object description'].dropna(how='all')
for name in df1:
if '10' in name:
cblist.append(name)
df3=pd.DataFrame
df4=pd.DataFrame
list=[]
a=0
while a<(len(cblist)):
for op in cblist[a]:
df2=df.loc[df['Object description'] == cblist[a]]
cablelist2 = df2[['Object ID']].values.T.tolist()[:][0]
for op in cablelist2:
dfByID = df.loc[df['under Rev. Parts no.'] == op]
print('\r\n')
df3 = df2.append(dfByID)
sorted_df3 = df3.sort_index()
df4 = sorted_df3.update
print(sorted_df3)
break
a += 1
期望輸出的結果如下,本結果還希望寫入excel表格,因此如何將所有sorted_df3 的結果集合起來呢
Sort Lev under Rev. Parts no. ... Net Gross Quantity.1
20 4074 ...3 10263305 ... 1.017 1.017 1
21 4075 ....4 10259566 ... 0.000 0.000 1
22 4076 ....4 10259566 ... 0.005 0.005 5
23 4077 ....4 10259566 ... 0.005 0.005 5
24 4078 ....4 10259566 ... 0.001 0.001 1
[5 rows x 36 columns]
Sort Lev under Rev. Parts no. ... Net Gross Quantity.1
25 4131 ...3 10263305 ... 1.03 1.03 1
26 4132 ....4 10259573 ... 0.00 0.00 1
[2 rows x 36 columns]
目前結果只能輸出最后一個結果
append 這個指令沒辦法用 因為每次輸出的sorted_df3是不一樣的但是名字是一樣的。無法定義每次輸出結果的名字。
感謝閱讀
uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/107905.html
上一篇:python的re正則re.findall('(((ab)))','abab'))
下一篇:goland grpc配置
