-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataPreparator.py
47 lines (33 loc) · 1.3 KB
/
dataPreparator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import numpy as np
import pandas as pd
os.system('cls')
def numpyConvert(boardData: list):
return (np.array(boardData)).reshape(1, -1)
def dataFrameConvert(boardData: list):
columns: list = [
"ROW_1_1", "ROW_1_2", "ROW_1_3", "ROW_2_1", "ROW_2_2", "ROW_2_3",
"ROW_3_1", "ROW_3_2", "ROW_3_3"
]
board: dict = dict()
for i in range(len(columns)):
board[columns[i]] = [boardData[i]]
return numpyConvert(pd.DataFrame(data=board, columns=columns))
def dataFrameDummyVarConvert(boardData: list):
columns: list = [
'ROW_1_1_0', 'ROW_1_1_1', 'ROW_1_1_2', 'ROW_1_2_0', 'ROW_1_2_1',
'ROW_1_2_2', 'ROW_1_3_0', 'ROW_1_3_1', 'ROW_1_3_2', 'ROW_2_1_0',
'ROW_2_1_1', 'ROW_2_1_2', 'ROW_2_2_0', 'ROW_2_2_1', 'ROW_2_2_2',
'ROW_2_3_0', 'ROW_2_3_1', 'ROW_2_3_2', 'ROW_3_1_0', 'ROW_3_1_1',
'ROW_3_1_2', 'ROW_3_2_0', 'ROW_3_2_1', 'ROW_3_2_2', 'ROW_3_3_0',
'ROW_3_3_1', 'ROW_3_3_2'
]
board: dict = dict()
for i in range(len(columns)):
board[columns[i]] = [0]
for rowNo in range(1, 4):
for cellNo in range(1, 4):
board[f'ROW_{rowNo}_{cellNo}_{boardData[cellNo-1]}'] = [1]
return numpyConvert(pd.DataFrame(data=board, columns=columns))
if __name__ == '__main__':
print('Hello World')