-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
  • 119,623
  • 25
  • 170
  • 301
kaulmonish
  • 408
  • 5
  • 17

2 Answers2

1

Use :

>>> df.values.tolist()
akash karothiya
  • 5,736
  • 1
  • 19
  • 29
1

Simply, use as_matrix:

df.as_matrix()
zipa
  • 27,316
  • 6
  • 40
  • 58