2

I am working with probabilities, when I print the output, it looks as follows:

[[4.88915104e-308 1.43405787e-307 2.20709896e-308 ... 3.08740254e-307
  1.68481486e-307 1.72126050e-307]
 [1.64744295e-004 8.66082462e-004 7.66062761e-005 ... 1.85613403e-003
  9.68750380e-004 8.22260750e-004]
 [6.18964539e-004 1.85605606e-003 2.71300593e-004 ... 3.86232296e-003
  2.01921300e-003 2.18304351e-003]],

Is there a way in pandas to store it as a DataFrame?

Desired output:

Index Value


0                  [4.88915104e-308 1.43405787e-307 2.20709896e-308 ... 3.08740254e-307
                    1.68481486e-307 1.72126050e-307]

1                  [1.64744295e-004 8.66082462e-004 7.66062761e-005 ... 1.85613403e-003
                    9.68750380e-004 8.22260750e-004]

2                  [6.18964539e-004 1.85605606e-003 2.71300593e-004 ... 3.86232296e-003
                    2.01921300e-003 2.18304351e-003]

I tried a lot of ways but I get :

ValueError: Wrong number of items passed 6, placement implies 1

2
  • Could you provide the code which produces the error you are showing? Commented Jun 22, 2022 at 12:19
  • So you want the full values of arrays to be in the DataFrame cells? Why do you want them in a DataFrame, exactly? Commented Jun 22, 2022 at 12:19

1 Answer 1

2

Yes, it is possible if convert 2d array to list:

df = pd.DataFrame({'col':arr.tolist()})

Or:

s = pd.Series(arr.tolist())
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.