-7

I have a dataframe(df) like

col1, col2
a,1
b,2

I want to make it to a list of list like:

[
    [a, 1],
    [b, 2]
]

How can I do this?

martineau
  • 112,593
  • 23
  • 157
  • 280
kaulmonish
  • 388
  • 2
  • 17

2 Answers2

1

Use :

>>> df.values.tolist()
akash karothiya
  • 5,500
  • 1
  • 16
  • 26
1

Simply, use as_matrix:

df.as_matrix()
zipa
  • 26,044
  • 6
  • 38
  • 55