MCPcopy Create free account
hub / github.com/Giyn/DataMiningVisualizationSystem / pretreatment

Function pretreatment

App/main.py:87–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85
86@app.route('/api-pretreatment', methods = ['POST', 'GET'])
87def pretreatment() :
88
89 if request.method == 'POST':
90
91 data = json.loads(str(request.data, 'utf-8'))
92
93 dataSet = str(data['dataSet'])
94
95 df = Array2DataFrame(dataSet)
96
97 discrete = []
98
99 textColumn = None
100
101 if('dropColumns' in data) :
102
103 dataSet += str(data['dropColumns'])
104
105 if(len(data['dropColumns']) != 1 or data['dropColumns'][0] != '' ) : df = dropColumns(df, columns = data['dropColumns'])
106
107 df = df.dropna(axis = 0, how = 'any')
108
109 df = df.reset_index(drop=True)
110
111 if('discreteColumns' in data) :
112
113 dataSet += str(data['discreteColumns'])
114
115 discrete = data['discreteColumns']
116
117 if(len(data['discreteColumns']) != 1 or data['discreteColumns'][0] != '' ) : df = getDummies(df, columns = discrete)
118
119 if ('textColumn' in data):
120
121 dataSet += str(data['textColumn'])
122
123 if(data['textColumn'] != '' ) : textColumn = str(data['textColumn'])
124
125
126 hashKey = str(hash(dataSet))
127
128 pushDataSet(df, discrete, textColumn, hashKey)
129
130 if("Unnamed: 0" in df.columns) : df = dropColumns(df, columns = ["Unnamed: 0"])
131
132 return hashKey
133
134 return '<h1>请使用POST方法访问</h1>'
135
136
137

Callers

nothing calls this directly

Calls 4

Array2DataFrameFunction · 0.85
dropColumnsFunction · 0.85
getDummiesFunction · 0.85
pushDataSetFunction · 0.85

Tested by

no test coverage detected