close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ValueError: Shape of passed values is (1, 6), indices imply (6, 6) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ValueError: Shape of passed values is (1, 6), indices imply (6, 6) Error Occurs?

Today I get the following error ValueError: Shape of passed values is (1, 6), indices imply (6, 6) in python.

How To Solve ValueError: Shape of passed values is (1, 6), indices imply (6, 6) Error ?

  1. How To Solve ValueError: Shape of passed values is (1, 6), indices imply (6, 6) Error ?

    To Solve ValueError: Shape of passed values is (1, 6), indices imply (6, 6) Error I was having similar issues with making a dataframe from regressor coefficients (regressor.coeff_), and brackets gave another error asking for 2-d input.

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

    To Solve ValueError: Shape of passed values is (1, 6), indices imply (6, 6) Error I was having similar issues with making a dataframe from regressor coefficients (regressor.coeff_), and brackets gave another error asking for 2-d input.

Solution 1

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

Solution 2

I was having similar issues with making a dataframe from regressor coefficients (regressor.coeff_), and brackets gave another error asking for 2-d input. If you get this error, try appending the input array with [0] so it pulls the values out. ex: data[0]

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read