Je passe une liste de flask) à une autre fonction et j'obtiens cette valeur d'erreur.
Mon code à la fin de l'envoi:
@app.route('/process', methods=['POST'])
def process():
name = request.form['name']
comment = request.form['comment']
wickets = request.form['wickets']
ga = request.form['ga']
ppballs = request.form['ppballs']
overs = request.form['overs']
score = [name,comment,wickets,ga,ppballs,overs]
results = []
results = eval_score(score)
print results
Extrémité du récepteur:
def ml_model(data):
col = pd.DataFrame(data,columns=['runs','balls', 'wickets', 'ground_average', 'pp_balls_left', 'total_overs'])
predicted = predictor(col)
Trace d'erreur:
...
line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/sbk/guestbook/guestbook.py", line 26, in process
results = eval_score(score)
File "/Users/sbk/guestbook/eval_score.py", line 6, in eval_score
col = pd.DataFrame(data,columns=['runs','balls', 'wickets', 'ground_average', 'pp_balls_left', 'total_overs'])
File "/Users/sbk/anaconda2/lib/python2.7/site- packages/pandas/core/frame.py", line 385, in __init__
copy=copy)
File "/Users/sbk/anaconda2/lib/python2.7/site-packages/pandas/core/frame.py", line 533, in _init_ndarray
return create_block_manager_from_blocks([values], [columns, index])
File "/Users/sbk/anaconda2/lib/python2.7/site-packages/pandas/core/internals.py", line 4631, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File "/Users/sbk/anaconda2/lib/python2.7/site-packages/pandas/core/internals.py", line 4608, in construction_error
Open an interactive python Shell in this framepassed, implied))
S'il vous plaît laissez-moi savoir où je vais mal.
Il suffit de changer
col = pd.DataFrame(data, columns=['runs','balls', 'wickets', 'ground_average', 'pp_balls_left', 'total_overs'])
for
col = pd.DataFrame([data], columns=['runs','balls', 'wickets', 'ground_average', 'pp_balls_left', 'total_overs'])
Tu veux [data]
pour pandas
comprendre ce sont des lignes.
Illustration simple:
a = [1, 2, 3]
>>> pd.DataFrame(a)
0
0 1
1 2
2 3
>>> pd.DataFrame([a])
0 1 2
0 1 2 3