0

I have 3 numpy arrays with the following shapes:

a.shape = (120,)
b.shape = (120,)
c.shape = (120,)

I'm trying to create dataframe with the following way:

df = pd.DataFrame(data = [a, b, c], columns = ["a", "b", "c"])

and I'm getting the following error:

ValueError: 3 columns passed, passed data had 120 columns.

How can I create this dataframe with the 3 columns ?

1 Answer 1

1

Let's try

df = pd.DataFrame(data = [a, b, c], index = ["a", "b", "c"]).T
# or
df = pd.DataFrame(data = {'a': a, 'b': b, 'c': c})
print(df)

       a    b    c
0      0    0    0
1      1    1    1
2      2    2    2
3      3    3    3
4      4    4    4
..   ...  ...  ...
115  115  115  115
116  116  116  116
117  117  117  117
118  118  118  118
119  119  119  119

[120 rows x 3 columns]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.