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?
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?
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]]
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]])