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

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


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)   00  11  22  3>>> pd.DataFrame([a])   0  1  20  1  2  3


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]


I was facing the similar error with the message

Shape of passed values is (68, 1783), indices imply (68, 68) in dataframe

And As per my guess, I fed the transpose of ndarray of data and that solved the problem

Changed from

Features_Dataframe = pd.DataFrame(data=Features, columns=Feature_Labels)  # here Features ndarray is 68*1783

To

Features_Dataframe = pd.DataFrame(data=Features.transpose(), columns=Feature_Labels)  # Now Features array became 1783*68 i.e., 1783 rows and 68 columns