Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 445
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 7
Kenil Vasani
Asked: December 11, 20202020-12-11T20:37:11+00:00 2020-12-11T20:37:11+00:00In: Python

ValueError: Shape of passed values is (1, 6), indices imply (6, 6)

  • 7

I am passing a list from flask function to another function, and getting this value error.

My code at sending end:

@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

Receiver end :

def ml_model(data):
    col = pd.DataFrame(data,columns=['runs','balls', 'wickets', 'ground_average', 'pp_balls_left', 'total_overs'])
    predicted = predictor(col)

Trace of Error:

 ...
 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))

Please let me know where I am going wrong.

flaskpandaspythonvalueerror
  • 1 1 Answer
  • 9 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Rohit Patel

      Rohit Patel

      • 0 Questions
      • 98 Answers
      • 0 Best Answers
      • 0 Points
      View Profile
      Best Answer
      Rohit Patel
      2020-12-11T20:35:26+00:00Added an answer on December 11, 2020 at 8:35 pm

      Simply change

      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'])
      

      You want [data] for pandas to understand they’re rows.


      Simple illustration:

      a = [1, 2, 3]
      >>> pd.DataFrame(a)
         0
      0  1
      1  2
      2  3
      
      >>> pd.DataFrame([a])
         0  1  2
      0  1  2  3
      
      • 5
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains ...

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com