DataFrame creation incorrect error message (original) (raw)

The problem was already mentioned as part of other issues, but still persists in 0.22

#8020
blaze/blaze#466

Reported both expected shape and input data shape are both transposed which causes a lot of confusion. In my opinion, the reference value should be DataFrame.shape.

my_arr = np.array([1, 2, 3]) print("my_arr.shape: {}".format(my_arr.shape)) df = pd.DataFrame(index=[0], columns=range(0, 4), data=my_arr)

my_arr.shape: (3,) Traceback (most recent call last): ... ValueError: Shape of passed values is (1, 3), indices imply (4, 1)

Below are shapes which are expected to be reported:

my_arr = np.array([[0, 1, 2, 3]]) print("my_arr.shape: {}".format(my_arr.shape)) df = pd.DataFrame(index=[0], columns=range(0, 4), data=my_arr) print(df.shape)`

my_arr.shape: (1, 4) (1, 4)

I'm not sure, whether this is another issue, but in the first example, the error cause is 1-dimensional data while constructor expects 2-dimensional data. The user gets no hint about this from the error message.