0

I am new to Pandas. I have two arrays var and esvar with 1000 values each. When I am trying to put it into a dataframe. I am getting one single row. I have tried transposing the matrices but still gives me the same result.

df = pd.DataFrame({'VaR':[var],'ESVaR':[esvar]})
print(df)

Also tried:

df = pd.DataFrame({'VaR':var[:,0],'ESVaR':esvar[:,1]})
print(df)

(This gives me too many indices error)

This is result from first one but I want the below in multiple rows and not one row.

VaR                                              ESVaR
0  [-0.10515868551869557, -0.11579987587576174, -...  [-0.09180443392815332, -0.10857606448322654, -...
2
  • 1
    Get rid of the square brackets around car and esvar. Commented Mar 28, 2019 at 21:30
  • Thanks that worked! Commented Mar 28, 2019 at 21:31

2 Answers 2

1

just drop the list symbols around your variables and you are good to go:

df = pd.DataFrame({'VaR': var,'ESVaR': esvar})

Since var and esvar are already lists, your notation makes lists from lists and hence results in only one row in the DataFrame.

Sign up to request clarification or add additional context in comments.

Comments

0

As mentioned by Quang Hoang

df = pd.DataFrame({'VaR':var,'ESVaR':esvar})
print(df)

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.