Skip to content

Commit dcb80b6

Browse files
committed
DataFrame solve all problems
1 parent c521a2a commit dcb80b6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Class/KnowledgeBase.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import glob
22

33
import pandas as pd
4+
import pandas.DataFrame as df
45

5-
import Matrix
66
from Class.Match import Match
77
from Class.Port import Port
88

@@ -12,7 +12,7 @@ def __init__(self, matchList: [Match] = [Match], outPortList: [Port] = [Port], i
1212
self.matchList = matchList
1313
self.portListDict = {str: [Port]}
1414
self.portDict = {str: Port}
15-
self.matrixDict = {str: Matrix} # in,out,match
15+
self.dfDict = {str: df} # in,out,match
1616

1717
def learn_folder(self, path2folder='..\excel\learn/220-母线&线路-第一套合并单元&第一套合并单元'):
1818
for filename in glob.iglob(path2folder + '**/*.xls', recursive=True):
@@ -29,9 +29,9 @@ def learn_excel(self, path2excel):
2929
inPort = Port(row[1]['开入端子描述'], row[1]['开入端子引用'])
3030
match = Match(outPort, inPort)
3131
self.matchList.append(match)
32-
matrix = self.matrixDict.get('开出', Matrix)
32+
df = self.dfDict.get('开出', df)
3333
key = row[1]['开出端子描述'] + row[1]['开出端子引用']
34-
port = matrix.get(key)
34+
port = df.get(key)
3535
except RuntimeError:
3636
print(row[1])
3737
print(dir(self.matchList))
@@ -46,11 +46,11 @@ def load_excel(self, path2excel='..\excel\learn/220-母线&线路-第一套合
4646
portList.append(port)
4747
key2 = row[1][title + '端子描述'] + title + row[1][title + '端子引用']
4848
self.portDict[key2] = port
49-
matrix = self.matrixDict.get(title, Matrix)
49+
df = self.dfDict.get(title, df)
5050
if sheetName == '已配置':
51-
matrix[key2] = matrix.get(key2, {object: float})
51+
df[key2] = df.get(key2, {object: float})
5252
else: # new
53-
for done in matrix:
53+
for done in df:
5454
done[key2] = done.get(key2, float) # is autoFill metaData useful?
5555
self.portListDict[key] = portList
5656
except RuntimeError:

Matrix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from Class import Port
22
from Class.Object import Object
3+
import pandas as pd
34

45

56
class Matrix(Object):
67

78
def __init__(self, row: [], column: []):
89
self.row = row
910
self.column = column
10-
self = {object: {object: float}}
11+
self = pd.DataFrame
1112

1213
def set_row(self, row: []):
1314
self.row = row

0 commit comments

Comments
 (0)