Skip to content Skip to sidebar Skip to footer

Valueerror: Shape Of Passed Values Is (3, 27), Indices Imply (4, 27) # Pandas Dataframe

Here is my numpy array: import numpy as np num = np.array([[ 0.17899619 0.33093259 0.2076353 0.06130814] [ 0.20392888 0.42653105 0.33325891 0.10473969]

Solution 1:

Update: Make sure that big_array has 4 columns. The shape of big_array does not match the shape of your sample array num. That's why the example code is working, but your real code not.


I was unable to reproduce your error message. On my system (Windows, Python 2.7, pandas-0.11.0, numpy-1.7.1) everything works as expected when running the following code:

import numpy as np
import pandas as pd

num = np.array([[ 0.17899619,  0.33093259,  0.2076353,   0.06130814],
                [ 0.20392888,  0.42653105,  0.33325891,  0.10473969],
                [ 0.17038247,  0.19081956,  0.10119709,  0.09032416],
                [-0.10606583, -0.13680513, -0.13129103, -0.03684349],
                [ 0.20319428,  0.28340985,  0.20994867,  0.11728491],
                [ 0.04396872,  0.23703525,  0.09359683,  0.11486036],
                [ 0.27801304, -0.05769304, -0.06202813,  0.04722761]])

days = ['5 days', '10 days', '20 days', '60 days']
prices = ['AAPL', 'ADBE', 'AMD', 'AMZN', 'CRM', 'EXPE', 'FB']

print pd.DataFrame(num, index=prices, columns=days).to_html()

Post a Comment for "Valueerror: Shape Of Passed Values Is (3, 27), Indices Imply (4, 27) # Pandas Dataframe"