0

I have a dataframe:

col1   col2   col3
1       4      6
5       2      3
6       1      0

I want to turn it into nested list:

array([[1,5,6],[4,2,1],[6,3,0]])

How could i do that?

0

2 Answers 2

2

Wouldn't df.T.values work?


array([[1, 5, 6],
       [4, 2, 1],
       [6, 3, 0]], dtype=int64)

or df.T.values.tolist()


[[1, 5, 6], [4, 2, 1], [6, 3, 0]]
Sign up to request clarification or add additional context in comments.

Comments

0

try this:

df=  pd.DataFrame([[1,4,6],[5,2,3],[6,1,0]])

df.T.values
### returns >> array([[1,5,6],[4,2,1],[6,3,0]])

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.